From 17706144e9dc6c2dfde580b7821f18c5f6924682 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Wed, 22 Jan 2020 21:35:32 +0000 Subject: Geometry refactoring Move QBuffer, QAttribute, QGeometry to Qt3DCore. Change-Id: I59dfd091eefadcada93350b3aba955f40b304385 Reviewed-by: Paul Lemire --- .../qt3d/instanced-arrays-qml/instancebuffer.cpp | 2 +- .../qt3d/instanced-arrays-qml/instancebuffer.h | 4 +- src/animation/backend/animationclip.cpp | 4 +- src/animation/backend/gltfimporter.cpp | 36 +- src/animation/backend/gltfimporter_p.h | 8 +- src/animation/frontend/qmorphinganimation.cpp | 8 +- src/animation/frontend/qmorphtarget.cpp | 22 +- src/animation/frontend/qmorphtarget.h | 14 +- src/animation/frontend/qmorphtarget_p.h | 2 +- src/animation/frontend/qvertexblendanimation.cpp | 12 +- src/core/core.pri | 2 + src/core/core.pro | 1 + src/core/geometry/geometry.pri | 17 + src/core/geometry/qabstractfunctor.cpp | 97 ++++ src/core/geometry/qabstractfunctor.h | 107 +++++ src/core/geometry/qattribute.cpp | 492 ++++++++++++++++++++ src/core/geometry/qattribute.h | 157 +++++++ src/core/geometry/qattribute_p.h | 87 ++++ src/core/geometry/qbuffer.cpp | 314 +++++++++++++ src/core/geometry/qbuffer.h | 128 ++++++ src/core/geometry/qbuffer_p.h | 90 ++++ src/core/geometry/qgeometry.cpp | 264 +++++++++++ src/core/geometry/qgeometry.h | 89 ++++ src/core/geometry/qgeometry_p.h | 86 ++++ src/core/geometry/qgeometryfactory_p.h | 80 ++++ src/core/qurlhelper.cpp | 68 +++ src/core/qurlhelper_p.h | 71 +++ src/doc/src/qt3drender-geometry.qdoc | 12 +- src/extras/3dtext/qextrudedtextgeometry.cpp | 38 +- src/extras/3dtext/qextrudedtextgeometry.h | 20 +- src/extras/3dtext/qextrudedtextgeometry_p.h | 19 +- src/extras/geometries/qconegeometry.cpp | 12 +- src/extras/geometries/qconegeometry.h | 22 +- src/extras/geometries/qconegeometry_p.h | 22 +- src/extras/geometries/qconemesh.cpp | 4 +- src/extras/geometries/qconemesh.h | 2 +- src/extras/geometries/qcuboidgeometry.cpp | 24 +- src/extras/geometries/qcuboidgeometry.h | 28 +- src/extras/geometries/qcuboidgeometry_p.h | 23 +- src/extras/geometries/qcuboidmesh.h | 2 +- src/extras/geometries/qcylindergeometry.cpp | 12 +- src/extras/geometries/qcylindergeometry.h | 24 +- src/extras/geometries/qcylindergeometry_p.h | 21 +- src/extras/geometries/qcylindermesh.cpp | 5 +- src/extras/geometries/qcylindermesh.h | 4 +- src/extras/geometries/qplanegeometry.cpp | 10 +- src/extras/geometries/qplanegeometry.h | 28 +- src/extras/geometries/qplanegeometry_p.h | 23 +- src/extras/geometries/qplanemesh.h | 4 +- src/extras/geometries/qspheregeometry.cpp | 12 +- src/extras/geometries/qspheregeometry.h | 28 +- src/extras/geometries/qspheregeometry_p.h | 27 +- src/extras/geometries/qspheremesh.h | 2 +- src/extras/geometries/qtorusgeometry.cpp | 12 +- src/extras/geometries/qtorusgeometry.h | 24 +- src/extras/geometries/qtorusgeometry_p.h | 23 +- src/extras/geometries/qtorusmesh.h | 2 +- src/extras/text/distancefieldtextrenderer.cpp | 34 +- src/extras/text/distancefieldtextrenderer_p_p.h | 19 +- src/extras/text/qtext2dentity.cpp | 6 +- src/extras/text/qtextureatlas.cpp | 2 +- .../geometryloaders/default/basegeometryloader.cpp | 10 +- .../geometryloaders/default/basegeometryloader_p.h | 10 +- .../geometryloaders/fbx/fbxgeometryloader.cpp | 6 +- .../geometryloaders/gltf/gltfgeometryloader.cpp | 16 +- .../geometryloaders/gltf/gltfgeometryloader.h | 21 +- .../opengl/graphicshelpers/graphicscontext.cpp | 6 +- .../opengl/graphicshelpers/graphicscontext_p.h | 4 +- .../opengl/graphicshelpers/submissioncontext.cpp | 6 +- .../opengl/graphicshelpers/submissioncontext_p.h | 1 - src/plugins/renderers/opengl/renderer/renderer.cpp | 2 +- .../renderers/opengl/renderer/renderview.cpp | 10 +- src/plugins/sceneparsers/assimp/assimpimporter.cpp | 28 +- src/plugins/sceneparsers/gltf/gltfimporter.cpp | 8 +- src/plugins/sceneparsers/gltf/gltfimporter.h | 10 +- .../sceneparsers/gltfexport/gltfexporter.cpp | 6 +- src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp | 12 + .../imports/render/qt3dquick3drenderplugin.cpp | 12 - src/quick3d/quick3d/items/items.pri | 8 +- src/quick3d/quick3d/items/quick3dbuffer.cpp | 139 ++++++ src/quick3d/quick3d/items/quick3dbuffer_p.h | 102 +++++ src/quick3d/quick3d/items/quick3dgeometry.cpp | 91 ++++ src/quick3d/quick3d/items/quick3dgeometry_p.h | 90 ++++ .../quick3danimation/items/quick3dmorphtarget.cpp | 16 +- .../quick3danimation/items/quick3dmorphtarget_p.h | 12 +- src/quick3d/quick3drender/items/items.pri | 4 - src/quick3d/quick3drender/items/quick3dbuffer.cpp | 145 ------ src/quick3d/quick3drender/items/quick3dbuffer_p.h | 106 ----- .../quick3drender/items/quick3dgeometry.cpp | 93 ---- .../quick3drender/items/quick3dgeometry_p.h | 92 ---- src/quick3d/quick3dscene2d/items/scene2d.cpp | 2 +- src/render/backend/bufferutils_p.h | 28 +- src/render/backend/buffervisitor_p.h | 18 +- src/render/backend/trianglesvisitor.cpp | 2 + src/render/backend/trianglesvisitor_p.h | 1 - src/render/backend/visitorutils_p.h | 42 +- src/render/framegraph/qbuffercapture.h | 2 +- src/render/frontend/qabstractfunctor.cpp | 97 ---- src/render/frontend/qabstractfunctor.h | 107 ----- src/render/frontend/qrenderaspect.cpp | 20 +- src/render/frontend/render-frontend.pri | 2 - src/render/geometry/attribute.cpp | 3 +- src/render/geometry/attribute_p.h | 10 +- src/render/geometry/buffer.cpp | 24 +- src/render/geometry/buffer_p.h | 22 +- src/render/geometry/geometry.cpp | 6 +- src/render/geometry/geometry.pri | 10 - src/render/geometry/geometryrenderer.cpp | 6 +- src/render/geometry/geometryrenderer_p.h | 8 +- src/render/geometry/gltfskeletonloader.cpp | 2 + src/render/geometry/gltfskeletonloader_p.h | 8 +- src/render/geometry/qattribute.cpp | 493 --------------------- src/render/geometry/qattribute.h | 157 ------- src/render/geometry/qattribute_p.h | 87 ---- src/render/geometry/qbuffer.cpp | 314 ------------- src/render/geometry/qbuffer.h | 128 ------ src/render/geometry/qbuffer_p.h | 90 ---- src/render/geometry/qgeometry.cpp | 268 ----------- src/render/geometry/qgeometry.h | 89 ---- src/render/geometry/qgeometry_p.h | 83 ---- src/render/geometry/qgeometryfactory_p.h | 81 ---- src/render/geometry/qgeometryrenderer.cpp | 2 +- src/render/geometry/qgeometryrenderer.h | 16 +- src/render/geometry/qgeometryrenderer_p.h | 6 +- src/render/geometry/qmesh.cpp | 16 +- src/render/geometry/qmesh_p.h | 9 +- src/render/io/io.pri | 2 - src/render/io/qgeometryloaderinterface_p.h | 8 +- src/render/io/qurlhelper.cpp | 68 --- src/render/io/qurlhelper_p.h | 71 --- src/render/jobs/calcboundingvolumejob.cpp | 10 +- src/render/jobs/loadbufferjob.cpp | 6 +- src/render/jobs/loadscenejob.cpp | 4 +- src/render/jobs/loadskeletonjob.cpp | 4 +- src/render/jobs/sendbuffercapturejob.cpp | 6 +- src/render/materialsystem/parameter.cpp | 1 - src/render/materialsystem/qshaderprogram.cpp | 4 +- .../materialsystem/qshaderprogrambuilder.cpp | 1 - src/render/materialsystem/shaderbuilder.cpp | 4 +- src/render/picking/objectpicker.cpp | 1 - src/render/picking/qobjectpicker.cpp | 2 +- src/render/picking/qobjectpicker.h | 1 - src/render/texture/qtexture.cpp | 4 +- src/render/texture/qtexturegenerator_p.h | 4 +- src/render/texture/qtextureimage_p.h | 1 - src/render/texture/qtextureimagedata.cpp | 2 +- src/render/texture/qtextureimagedatagenerator.h | 5 +- .../qmorphinganimation/tst_qmorphinganimation.cpp | 18 +- .../animation/qmorphtarget/tst_qmorphtarget.cpp | 32 +- tests/auto/extras/common/geometrytesthelper.h | 14 +- .../extras/qcuboidgeometry/tst_qcuboidgeometry.cpp | 28 +- .../extras/qtorusgeometry/tst_qtorusgeometry.cpp | 28 +- tests/auto/quick3d/3dcore/3dcore.qml | 4 + tests/auto/quick3d/3drender/3drender.qml | 4 - tests/auto/quick3d/quick3dbuffer/quick3dbuffer.pro | 2 +- .../quick3d/quick3dbuffer/tst_quick3dbuffer.cpp | 6 +- tests/auto/render/attribute/tst_attribute.cpp | 46 +- .../render/boundingsphere/tst_boundingsphere.cpp | 34 +- tests/auto/render/buffer/tst_buffer.cpp | 38 +- .../coordinatereader/tst_coordinatereader.cpp | 70 +-- tests/auto/render/geometry/tst_geometry.cpp | 32 +- .../render/geometryloaders/tst_geometryloaders.cpp | 5 +- .../geometryrenderer/tst_geometryrenderer.cpp | 14 +- tests/auto/render/gltfplugins/tst_gltfplugins.cpp | 136 +++--- .../auto/render/meshfunctors/tst_meshfunctors.cpp | 33 +- tests/auto/render/opengl/textures/tst_textures.cpp | 4 +- tests/auto/render/picking/tst_picking.cpp | 6 +- .../proximityfiltering/tst_proximityfiltering.cpp | 18 +- tests/auto/render/qattribute/tst_qattribute.cpp | 56 +-- tests/auto/render/qbuffer/tst_qbuffer.cpp | 12 +- tests/auto/render/qgeometry/tst_qgeometry.cpp | 24 +- .../qgeometryrenderer/tst_qgeometryrenderer.cpp | 18 +- tests/auto/render/scene2d/tst_scene2d.cpp | 22 +- .../render/segmentvisitor/tst_segmentvisitor.cpp | 130 +++--- .../render/trianglevisitor/tst_trianglevisitor.cpp | 162 +++---- .../tst_updatemeshtrianglelistjob.cpp | 12 +- tests/manual/buffercapture-qml/main.cpp | 4 +- tests/manual/custom-mesh-cpp-indirect/main.cpp | 82 ++-- tests/manual/custom-mesh-cpp/main.cpp | 42 +- tests/manual/custom-mesh-update-data-cpp/main.cpp | 38 +- tests/manual/mesh-morphing/main.cpp | 4 +- .../tessellation-modes/tessellatedquadmesh.cpp | 22 +- 182 files changed, 3770 insertions(+), 3776 deletions(-) create mode 100644 src/core/geometry/geometry.pri create mode 100644 src/core/geometry/qabstractfunctor.cpp create mode 100644 src/core/geometry/qabstractfunctor.h create mode 100644 src/core/geometry/qattribute.cpp create mode 100644 src/core/geometry/qattribute.h create mode 100644 src/core/geometry/qattribute_p.h create mode 100644 src/core/geometry/qbuffer.cpp create mode 100644 src/core/geometry/qbuffer.h create mode 100644 src/core/geometry/qbuffer_p.h create mode 100644 src/core/geometry/qgeometry.cpp create mode 100644 src/core/geometry/qgeometry.h create mode 100644 src/core/geometry/qgeometry_p.h create mode 100644 src/core/geometry/qgeometryfactory_p.h create mode 100644 src/core/qurlhelper.cpp create mode 100644 src/core/qurlhelper_p.h create mode 100644 src/quick3d/quick3d/items/quick3dbuffer.cpp create mode 100644 src/quick3d/quick3d/items/quick3dbuffer_p.h create mode 100644 src/quick3d/quick3d/items/quick3dgeometry.cpp create mode 100644 src/quick3d/quick3d/items/quick3dgeometry_p.h delete mode 100644 src/quick3d/quick3drender/items/quick3dbuffer.cpp delete mode 100644 src/quick3d/quick3drender/items/quick3dbuffer_p.h delete mode 100644 src/quick3d/quick3drender/items/quick3dgeometry.cpp delete mode 100644 src/quick3d/quick3drender/items/quick3dgeometry_p.h delete mode 100644 src/render/frontend/qabstractfunctor.cpp delete mode 100644 src/render/frontend/qabstractfunctor.h delete mode 100644 src/render/geometry/qattribute.cpp delete mode 100644 src/render/geometry/qattribute.h delete mode 100644 src/render/geometry/qattribute_p.h delete mode 100644 src/render/geometry/qbuffer.cpp delete mode 100644 src/render/geometry/qbuffer.h delete mode 100644 src/render/geometry/qbuffer_p.h delete mode 100644 src/render/geometry/qgeometry.cpp delete mode 100644 src/render/geometry/qgeometry.h delete mode 100644 src/render/geometry/qgeometry_p.h delete mode 100644 src/render/geometry/qgeometryfactory_p.h delete mode 100644 src/render/io/qurlhelper.cpp delete mode 100644 src/render/io/qurlhelper_p.h diff --git a/examples/qt3d/instanced-arrays-qml/instancebuffer.cpp b/examples/qt3d/instanced-arrays-qml/instancebuffer.cpp index 770d1b425..bf76706f0 100644 --- a/examples/qt3d/instanced-arrays-qml/instancebuffer.cpp +++ b/examples/qt3d/instanced-arrays-qml/instancebuffer.cpp @@ -57,7 +57,7 @@ static const int colCount = 20; static const int maxInstanceCount = rowCount * colCount; InstanceBuffer::InstanceBuffer(Qt3DCore::QNode *parent) - : Qt3DRender::QBuffer(parent) + : Qt3DCore::QBuffer(parent) , m_instanceCount(maxInstanceCount) { // Create some per instance data - position of each instance diff --git a/examples/qt3d/instanced-arrays-qml/instancebuffer.h b/examples/qt3d/instanced-arrays-qml/instancebuffer.h index 0c769cbf4..c26a85692 100644 --- a/examples/qt3d/instanced-arrays-qml/instancebuffer.h +++ b/examples/qt3d/instanced-arrays-qml/instancebuffer.h @@ -51,9 +51,9 @@ #ifndef INSTANCEBUFFER_H #define INSTANCEBUFFER_H -#include +#include -class InstanceBuffer : public Qt3DRender::QBuffer +class InstanceBuffer : public Qt3DCore::QBuffer { Q_OBJECT Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged) diff --git a/src/animation/backend/animationclip.cpp b/src/animation/backend/animationclip.cpp index 2c7e4fffb..9f18b5eed 100644 --- a/src/animation/backend/animationclip.cpp +++ b/src/animation/backend/animationclip.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -187,7 +187,7 @@ void AnimationClip::loadAnimation() void AnimationClip::loadAnimationFromUrl() { // TODO: Handle remote files - QString filePath = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_source); + QString filePath = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(m_source); QFile file(filePath); if (!file.open(QIODevice::ReadOnly)) { qWarning() << "Could not find animation clip:" << filePath; diff --git a/src/animation/backend/gltfimporter.cpp b/src/animation/backend/gltfimporter.cpp index f7907b3c2..82401dd5e 100644 --- a/src/animation/backend/gltfimporter.cpp +++ b/src/animation/backend/gltfimporter.cpp @@ -193,7 +193,7 @@ GLTFImporter::BufferView::BufferView(const QJsonObject &json) } GLTFImporter::AccessorData::AccessorData() - : type(Qt3DRender::QAttribute::Float) + : type(Qt3DCore::QAttribute::Float) , dataSize(0) , count(0) , byteOffset(0) @@ -369,39 +369,39 @@ GLTFImporter::Node::Node(const QJsonObject &json) skinIndex = skinValue.toInt(); } -Qt3DRender::QAttribute::VertexBaseType GLTFImporter::accessorTypeFromJSON(int componentType) +Qt3DCore::QAttribute::VertexBaseType GLTFImporter::accessorTypeFromJSON(int componentType) { if (componentType == GL_BYTE) - return Qt3DRender::QAttribute::Byte; + return Qt3DCore::QAttribute::Byte; else if (componentType == GL_UNSIGNED_BYTE) - return Qt3DRender::QAttribute::UnsignedByte; + return Qt3DCore::QAttribute::UnsignedByte; else if (componentType == GL_SHORT) - return Qt3DRender::QAttribute::Short; + return Qt3DCore::QAttribute::Short; else if (componentType == GL_UNSIGNED_SHORT) - return Qt3DRender::QAttribute::UnsignedShort; + return Qt3DCore::QAttribute::UnsignedShort; else if (componentType == GL_UNSIGNED_INT) - return Qt3DRender::QAttribute::UnsignedInt; + return Qt3DCore::QAttribute::UnsignedInt; else if (componentType == GL_FLOAT) - return Qt3DRender::QAttribute::Float; + return Qt3DCore::QAttribute::Float; // There shouldn't be an invalid case here qWarning("unsupported accessor type %d", componentType); - return Qt3DRender::QAttribute::Float; + return Qt3DCore::QAttribute::Float; } -uint GLTFImporter::accessorTypeSize(Qt3DRender::QAttribute::VertexBaseType componentType) +uint GLTFImporter::accessorTypeSize(Qt3DCore::QAttribute::VertexBaseType componentType) { switch (componentType) { - case Qt3DRender::QAttribute::Byte: - case Qt3DRender::QAttribute::UnsignedByte: + case Qt3DCore::QAttribute::Byte: + case Qt3DCore::QAttribute::UnsignedByte: return 1; - case Qt3DRender::QAttribute::Short: - case Qt3DRender::QAttribute::UnsignedShort: + case Qt3DCore::QAttribute::Short: + case Qt3DCore::QAttribute::UnsignedShort: return 2; - case Qt3DRender::QAttribute::Int: - case Qt3DRender::QAttribute::Float: + case Qt3DCore::QAttribute::Int: + case Qt3DCore::QAttribute::Float: return 4; default: @@ -522,12 +522,12 @@ GLTFImporter::AnimationNameAndChannels GLTFImporter::createAnimationData(int ani const auto &inputAccessor = m_accessors[sampler.inputAccessorIndex]; const auto &outputAccessor = m_accessors[sampler.outputAccessorIndex]; - if (inputAccessor.type != Qt3DRender::QAttribute::Float) { + if (inputAccessor.type != Qt3DCore::QAttribute::Float) { qWarning() << "Input accessor has wrong data type. Skipping channel."; continue; } - if (outputAccessor.type != Qt3DRender::QAttribute::Float) { + if (outputAccessor.type != Qt3DCore::QAttribute::Float) { qWarning() << "Output accessor has wrong data type. Skipping channel."; continue; } diff --git a/src/animation/backend/gltfimporter_p.h b/src/animation/backend/gltfimporter_p.h index e31f8d078..ef0486181 100644 --- a/src/animation/backend/gltfimporter_p.h +++ b/src/animation/backend/gltfimporter_p.h @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -100,7 +100,7 @@ public: explicit AccessorData(const QJsonObject &json); int bufferViewIndex; - Qt3DRender::QAttribute::VertexBaseType type; + Qt3DCore::QAttribute::VertexBaseType type; uint dataSize; int count; int byteOffset; @@ -190,8 +190,8 @@ public: AnimationNameAndChannels createAnimationData(int animationIndex, const QString &animationName = QString()) const; private: - static Qt3DRender::QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); - static uint accessorTypeSize(Qt3DRender::QAttribute::VertexBaseType componentType); + static Qt3DCore::QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); + static uint accessorTypeSize(Qt3DCore::QAttribute::VertexBaseType componentType); static uint accessorDataSizeFromJson(const QString &type); struct RawData diff --git a/src/animation/frontend/qmorphinganimation.cpp b/src/animation/frontend/qmorphinganimation.cpp index c73a6abd7..5b16668f9 100644 --- a/src/animation/frontend/qmorphinganimation.cpp +++ b/src/animation/frontend/qmorphinganimation.cpp @@ -50,7 +50,7 @@ namespace Qt3DAnimation { A Qt3DAnimation::QMorphingAnimation class implements blend-shape morphing animation to a target \l {Qt3DRender::QGeometryRenderer}{QGeometryRenderer}. The QMorphingAnimation - sets the correct \l {Qt3DRender::QAttribute}{QAttributes} from the + sets the correct \l {Qt3DCore::QAttribute}{QAttributes} from the \l {Qt3DAnimation::QMorphTarget}{morph targets} to the target \l {Qt3DRender::QGeometryRenderer::geometry} {QGeometryRenderer::geometry} and calculates interpolator for the current position. The actual blending between the attributes must @@ -248,16 +248,16 @@ void QMorphingAnimationPrivate::updateAnimation(float position) void QMorphingAnimationPrivate::setTargetInterpolated(int morphTarget) { QMorphTarget *target = m_morphTargets[morphTarget]; - Qt3DRender::QGeometry *geometry = m_target->geometry(); + Qt3DCore::QGeometry *geometry = m_target->geometry(); // remove attributes from previous frame if (m_currentTarget && (target != m_currentTarget)) { - const QVector targetAttributes = m_currentTarget->attributeList(); + const QVector targetAttributes = m_currentTarget->attributeList(); for (int i = 0; i < targetAttributes.size(); ++i) geometry->removeAttribute(targetAttributes.at(i)); } - const QVector targetAttributes = target->attributeList(); + const QVector targetAttributes = target->attributeList(); // add attributes from current frame to the geometry if (target != m_currentTarget) { diff --git a/src/animation/frontend/qmorphtarget.cpp b/src/animation/frontend/qmorphtarget.cpp index da068d477..1edaf2445 100644 --- a/src/animation/frontend/qmorphtarget.cpp +++ b/src/animation/frontend/qmorphtarget.cpp @@ -49,9 +49,9 @@ namespace Qt3DAnimation { \inherits QObject A Qt3DAnimation::QMorphTarget class is a convenience class, which provides a list - of \l {Qt3DRender::QAttribute} {QAttributes}, which the QMorphingAnimation uses + of \l {Qt3DCore::QAttribute} {QAttributes}, which the QMorphingAnimation uses to animate geometry. A QMorphTarget can also be created based on existing - \l Qt3DRender::QGeometry. + \l Qt3DCore::QGeometry. */ /*! @@ -99,7 +99,7 @@ QMorphTargetPrivate::QMorphTargetPrivate() void QMorphTargetPrivate::updateAttributeNames() { m_attributeNames.clear(); - for (const Qt3DRender::QAttribute *attr : qAsConst(m_targetAttributes)) + for (const Qt3DCore::QAttribute *attr : qAsConst(m_targetAttributes)) m_attributeNames.push_back(attr->name()); } @@ -115,7 +115,7 @@ QMorphTarget::QMorphTarget(QObject *parent) /*! Returns a list of attributes contained in the morph target. */ -QVector QMorphTarget::attributeList() const +QVector QMorphTarget::attributeList() const { Q_D(const QMorphTarget); return d->m_targetAttributes; @@ -130,12 +130,12 @@ QStringList QMorphTarget::attributeNames() const /*! Sets \a attributes to the morph target. Old attributes are cleared. */ -void QMorphTarget::setAttributes(const QVector &attributes) +void QMorphTarget::setAttributes(const QVector &attributes) { Q_D(QMorphTarget); d->m_targetAttributes = attributes; d->m_attributeNames.clear(); - for (const Qt3DRender::QAttribute *attr : attributes) + for (const Qt3DCore::QAttribute *attr : attributes) d->m_attributeNames.push_back(attr->name()); emit attributeNamesChanged(d->m_attributeNames); @@ -145,10 +145,10 @@ void QMorphTarget::setAttributes(const QVector &attrib Adds an \a attribute the morph target. An attribute with the same name must not have been added previously to the morph target. */ -void QMorphTarget::addAttribute(Qt3DRender::QAttribute *attribute) +void QMorphTarget::addAttribute(Qt3DCore::QAttribute *attribute) { Q_D(QMorphTarget); - for (const Qt3DRender::QAttribute *attr : qAsConst(d->m_targetAttributes)) { + for (const Qt3DCore::QAttribute *attr : qAsConst(d->m_targetAttributes)) { if (attr->name() == attribute->name()) return; } @@ -160,7 +160,7 @@ void QMorphTarget::addAttribute(Qt3DRender::QAttribute *attribute) /*! Removes an \a attribute from the morph target. */ -void QMorphTarget::removeAttribute(Qt3DRender::QAttribute *attribute) +void QMorphTarget::removeAttribute(Qt3DCore::QAttribute *attribute) { Q_D(QMorphTarget); if (d->m_targetAttributes.contains(attribute)) { @@ -173,11 +173,11 @@ void QMorphTarget::removeAttribute(Qt3DRender::QAttribute *attribute) /*! Returns a morph target based on the \a attributes in the given \a geometry. */ -QMorphTarget *QMorphTarget::fromGeometry(Qt3DRender::QGeometry *geometry, const QStringList &attributes) +QMorphTarget *QMorphTarget::fromGeometry(Qt3DCore::QGeometry *geometry, const QStringList &attributes) { QMorphTarget *target = new QMorphTarget(); const auto geometryAttributes = geometry->attributes(); - for (Qt3DRender::QAttribute *attr : geometryAttributes) { + for (Qt3DCore::QAttribute *attr : geometryAttributes) { if (attributes.contains(attr->name())) target->addAttribute(attr); } diff --git a/src/animation/frontend/qmorphtarget.h b/src/animation/frontend/qmorphtarget.h index ec9761c64..210a3be41 100644 --- a/src/animation/frontend/qmorphtarget.h +++ b/src/animation/frontend/qmorphtarget.h @@ -37,8 +37,8 @@ #ifndef QT3DANIMATION_QMORPHTARGET_H #define QT3DANIMATION_QMORPHTARGET_H -#include -#include +#include +#include #include @@ -58,14 +58,14 @@ class Q_3DANIMATIONSHARED_EXPORT QMorphTarget : public QObject public: explicit QMorphTarget(QObject *parent = nullptr); - QVector attributeList() const; + QVector attributeList() const; QStringList attributeNames() const; - void setAttributes(const QVector &attributes); - void addAttribute(Qt3DRender::QAttribute *attribute); - void removeAttribute(Qt3DRender::QAttribute *attribute); + void setAttributes(const QVector &attributes); + void addAttribute(Qt3DCore::QAttribute *attribute); + void removeAttribute(Qt3DCore::QAttribute *attribute); - Q_INVOKABLE static QMorphTarget *fromGeometry(Qt3DRender::QGeometry *geometry, + Q_INVOKABLE static QMorphTarget *fromGeometry(Qt3DCore::QGeometry *geometry, const QStringList &attributes); Q_SIGNALS: diff --git a/src/animation/frontend/qmorphtarget_p.h b/src/animation/frontend/qmorphtarget_p.h index 1fc3734ae..3214043f4 100644 --- a/src/animation/frontend/qmorphtarget_p.h +++ b/src/animation/frontend/qmorphtarget_p.h @@ -64,7 +64,7 @@ public: void updateAttributeNames(); QStringList m_attributeNames; - QVector m_targetAttributes; + QVector m_targetAttributes; Q_DECLARE_PUBLIC(QMorphTarget) }; diff --git a/src/animation/frontend/qvertexblendanimation.cpp b/src/animation/frontend/qvertexblendanimation.cpp index 143b9553a..77ba9a301 100644 --- a/src/animation/frontend/qvertexblendanimation.cpp +++ b/src/animation/frontend/qvertexblendanimation.cpp @@ -51,7 +51,7 @@ namespace Qt3DAnimation { A Qt3DAnimation::QVertexBlendAnimation class implements vertex-blend morphing animation to a target \l {Qt3DRender::QGeometryRenderer}{QGeometryRenderer}. The QVertexBlendAnimation - sets the correct \l {Qt3DRender::QAttribute}{QAttributes} from the + sets the correct \l {Qt3DCore::QAttribute}{QAttributes} from the \l {Qt3DAnimation::QMorphTarget}{morph targets} to the target \l {Qt3DRender::QGeometryRenderer::geometry} {QGeometryRenderer::geometry} and calculates interpolator for the current position. Unlike with QMorphingAnimation, where the blending is @@ -189,21 +189,21 @@ void QVertexBlendAnimationPrivate::updateAnimation(float position) base = m_morphTargets.at(target0); target = m_morphTargets.at(target1); - Qt3DRender::QGeometry *geometry = m_target->geometry(); + Qt3DCore::QGeometry *geometry = m_target->geometry(); // remove attributes from previous frame if (m_currentBase && m_currentTarget && (base != m_currentBase || target != m_currentTarget)) { - const QVector baseAttributes = m_currentBase->attributeList(); - const QVector targetAttributes = m_currentTarget->attributeList(); + const QVector baseAttributes = m_currentBase->attributeList(); + const QVector targetAttributes = m_currentTarget->attributeList(); for (int i = 0; i < baseAttributes.size(); ++i) { geometry->removeAttribute(baseAttributes.at(i)); geometry->removeAttribute(targetAttributes.at(i)); } } - const QVector baseAttributes = base->attributeList(); - const QVector targetAttributes = target->attributeList(); + const QVector baseAttributes = base->attributeList(); + const QVector targetAttributes = target->attributeList(); const QStringList attributeNames = base->attributeNames(); // add attributes from current frame to the geometry diff --git a/src/core/core.pri b/src/core/core.pri index de80fb25f..5bc6e38d9 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -7,6 +7,7 @@ HEADERS += \ $$PWD/corelogging_p.h \ $$PWD/qchangearbiter_p.h \ $$PWD/qt3dcore_global_p.h \ + $$PWD/qurlhelper_p.h \ $$PWD/qscene_p.h SOURCES += \ @@ -14,4 +15,5 @@ SOURCES += \ $$PWD/qscheduler.cpp \ $$PWD/qchangearbiter.cpp \ $$PWD/corelogging.cpp \ + $$PWD/qurlhelper.cpp \ $$PWD/qscene.cpp diff --git a/src/core/core.pro b/src/core/core.pro index f333725c9..9b74780ff 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -10,6 +10,7 @@ gcov { include(core.pri) include(aspects/aspects.pri) +include(geometry/geometry.pri) include(jobs/jobs.pri) include(nodes/nodes.pri) include(transforms/transforms.pri) diff --git a/src/core/geometry/geometry.pri b/src/core/geometry/geometry.pri new file mode 100644 index 000000000..13756ccb3 --- /dev/null +++ b/src/core/geometry/geometry.pri @@ -0,0 +1,17 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qabstractfunctor.h \ + $$PWD/qattribute.h \ + $$PWD/qattribute_p.h \ + $$PWD/qbuffer.h \ + $$PWD/qbuffer_p.h \ + $$PWD/qgeometry_p.h \ + $$PWD/qgeometry.h \ + $$PWD/qgeometryfactory_p.h + +SOURCES += \ + $$PWD/qabstractfunctor.cpp \ + $$PWD/qattribute.cpp \ + $$PWD/qbuffer.cpp \ + $$PWD/qgeometry.cpp \ diff --git a/src/core/geometry/qabstractfunctor.cpp b/src/core/geometry/qabstractfunctor.cpp new file mode 100644 index 000000000..3bd774a4f --- /dev/null +++ b/src/core/geometry/qabstractfunctor.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qabstractfunctor.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +/*! + \class Qt3DCore::QAbstractFunctor + \inmodule Qt3DCore + \since 5.7 + \brief QAbstractFunctor is an abstract base class for all functors. + + The QAbstractFunctor is used as a base class for all functors and data + generators in Qt3DCore module. + + When user defines a new functor or generator, they need to implement the + \l QAbstractFunctor::id() method, which should be done using the \c {QT3D_FUNCTOR} + macro in the class definition. + */ +/*! + \fn qintptr Qt3DCore::QAbstractFunctor::id() const + + Returns a pointer to the id of the functor. + */ +/*! + \fn qintptr Qt3DCore::functorTypeId() + + Returns a pointer to the type id of the functor. +*/ +/*! + \macro QT3D_FUNCTOR(Class) + \relates Qt3DCore::QAbstractFunctor + + This macro assigns functor id to the \a Class, which is used by QAbstractFunctor::functor_cast + to determine if the cast can be done. + */ + +/*! + \fn template const T * Qt3DCore::QAbstractFunctor::functor_cast(const QAbstractFunctor *other) const + + This method is used to cast functor \a other to type T if the other is of + type T (or of subclass); otherwise returns 0. This method works similarly + to \l [QtCore] {qobject_cast(const QObject *object)}{qobject_cast()}, + except with functors derived from QAbstractFunctor. + + \warning If T was not declared with \l QT3D_FUNCTOR macro, then the results are undefined. + */ + +/*! Desctructor */ +QAbstractFunctor::~QAbstractFunctor() +{ + +} + +} // Qt3D + +QT_END_NAMESPACE + diff --git a/src/core/geometry/qabstractfunctor.h b/src/core/geometry/qabstractfunctor.h new file mode 100644 index 000000000..9bd6e670b --- /dev/null +++ b/src/core/geometry/qabstractfunctor.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QABSTRACTFUNCTOR_H +#define QT3DCORE_QABSTRACTFUNCTOR_H + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +// This will generate a unique id() function per type +// <=> 1 unique function address per type +template +struct FunctorType +{ + static qintptr id() + { + // The MSVC linker can under some cases optimize all the template + // functions into a single function. The code below is there to ensure + // that the linker won't collapse all these distincts functions into one + static T *t = nullptr; + return reinterpret_cast(t); + } +}; + +template +qintptr functorTypeId() +{ + return reinterpret_cast(&FunctorType::id); +} + +#define QT3D_FUNCTOR(Class) \ + qintptr id() const override { \ + return Qt3DCore::functorTypeId(); \ + } + + +class Q_3DCORESHARED_EXPORT QAbstractFunctor +{ +public: + QAbstractFunctor() = default; + virtual ~QAbstractFunctor(); + virtual qintptr id() const = 0; + + // TODO: Remove when moving a copy of this to Qt3DCore + template + const T *functor_cast(const QAbstractFunctor *other) const + { + if (other->id() == functorTypeId()) + return static_cast(other); + return nullptr; + } +private: + Q_DISABLE_COPY(QAbstractFunctor) +}; + +template +const T *functor_cast(const QAbstractFunctor *other) +{ + if (other->id() == functorTypeId()) + return static_cast(other); + return nullptr; +} + +} // Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QABSTRACTFUNCTOR_H diff --git a/src/core/geometry/qattribute.cpp b/src/core/geometry/qattribute.cpp new file mode 100644 index 000000000..6be9c0203 --- /dev/null +++ b/src/core/geometry/qattribute.cpp @@ -0,0 +1,492 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qattribute.h" +#include "qattribute_p.h" +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +QAttributePrivate::QAttributePrivate() + : QNodePrivate() + , m_buffer(nullptr) + , m_name() + , m_vertexBaseType(QAttribute::Float) + , m_vertexSize(1) + , m_count(0) + , m_byteStride(0) + , m_byteOffset(0) + , m_divisor(0) + , m_attributeType(QAttribute::VertexAttribute) +{ +} + +/*! + * \qmltype Attribute + * \instantiates Qt3DCore::QAttribute + * \inqmlmodule Qt3D.Core + * \brief Defines an attribute and how data should be read from a Buffer. + * + * There are 3 types of attributes. + * \list + * \li VertexAttribute: used to define data to be read on a per vertex basis + * \li IndexAttribute: used to define vertex indices when indexed draw calls are + * to be used + *\li DrawIndirectAttribute: used to specify the DrawIndirect buffer to be used + * when indirect draw calls are to be used + * \endlist + * + * \note when an attribute is of type DrawIndirectAttribute, only count, stride + * and offset are relevant. + * + * When providing your own attributes, it may make sense to name your attribute + * using helpers such as QAttribute::defaultPositionAttributeName() as that + * will ensure your geometry will be compatible with picking and the various + * materials provided in the Qt3DExtras module. + */ + +/*! + * \class Qt3DCore::QAttribute + * \inheaderfile Qt3DCore/QAttribute + * \inmodule Qt3DCore + * + * \inherits Qt3DCore::QNode + * + * \brief Defines an attribute and how data should be read from a QBuffer. + * + * There are 3 types of attributes. + * \list + * \li VertexAttribute: used to define data to be read on a per vertex basis + * \li IndexAttribute: used to define vertex indices when indexed draw calls are + * to be used + *\li DrawIndirectAttribute: used to specify the DrawIndirect buffer to be used + * when indirect draw calls are to be used + * \endlist + * + * \note when an attribute is of type DrawIndirectAttribute, only count, stride + * and offset are relevant. + * + * When providing your own attributes, it may make sense to name your attribute + * using helpers such as QAttribute::defaultPositionAttributeName() as that + * will ensure your geometry will be compatible with picking and the various + * materials provided in the Qt3DExtras module. + * + * \sa QBuffer + */ + +/*! + * \typedef Qt3DCore::QBufferPtr + * \relates Qt3DCore::QAttribute + */ + +/*! + * \enum QAttribute::AttributeType + * + * The type of the attribute. + * + * \value VertexAttribute + * \value IndexAttribute + * \value DrawIndirectAttribute + */ + +/*! + * \enum QAttribute::VertexBaseType + * + * The type of the data. + * + * \value Byte + * \value UnsignedByte + * \value Short + * \value UnsignedShort + * \value Int + * \value UnsignedInt + * \value HalfFloat + * \value Float + * \value Double + */ + +/*! + * Constructs a new QAttribute with \a parent. + */ +QAttribute::QAttribute(QNode *parent) + : QNode(*new QAttributePrivate(), parent) +{ +} + +/*! + * Constructs a new QAttribute from \a buf of \a type, \a dataSize, \a count, \a offset, + * and \a stride with \a parent. + */ +QAttribute::QAttribute(QBuffer *buf, VertexBaseType type, uint dataSize, uint count, uint offset, uint stride, QNode *parent) + : QAttribute(parent) +{ + Q_D(QAttribute); + setBuffer(buf); + d->m_count = count; + d->m_byteOffset = offset; + d->m_vertexBaseType = type; + d->m_vertexSize = dataSize; + d->m_byteStride = stride; +} + + +/*! + * Constructs a new QAttribute named \a name from \a buf of \a type, \a + * dataSize, \a count, \a offset, and \a stride with \a parent. + */ +QAttribute::QAttribute(QBuffer *buf, const QString &name, VertexBaseType type, uint dataSize, uint count, uint offset, uint stride, QNode *parent) + : QAttribute(parent) +{ + Q_D(QAttribute); + setBuffer(buf); + d->m_name = name; + d->m_count = count; + d->m_byteOffset = offset; + d->m_vertexBaseType = type; + d->m_vertexSize = dataSize; + d->m_byteStride = stride; +} + +/*! \internal */ +QAttribute::~QAttribute() +{ +} + +/*! + * \property QAttribute::buffer + * + * Holds the buffer. + */ +QBuffer *QAttribute::buffer() const +{ + Q_D(const QAttribute); + return d->m_buffer; +} + +/*! + * \property QAttribute::name + * + * Holds the name. + */ +QString QAttribute::name() const +{ + Q_D(const QAttribute); + return d->m_name; +} + +/*! + * \property QAttribute::vertexSize + * + * Holds the data size, it can only be 1 to 4 units (scalars and vectors), + * 9 units (3x3 matrices) or 16 units (4x4 matrices). + */ +uint QAttribute::vertexSize() const +{ + Q_D(const QAttribute); + return d->m_vertexSize; +} + +/*! + * \property QAttribute::vertexBaseType + * + * Holds the data type. + */ +QAttribute::VertexBaseType QAttribute::vertexBaseType() const +{ + Q_D(const QAttribute); + return d->m_vertexBaseType; +} + +/*! + * \property QAttribute::count + * + * Holds the count. + */ +uint QAttribute::count() const +{ + Q_D(const QAttribute); + return d->m_count; +} + +/*! + * \property QAttribute::byteStride + * + * Holds the byte stride. + */ +uint QAttribute::byteStride() const +{ + Q_D(const QAttribute); + return d->m_byteStride; +} + +/*! + * \property QAttribute::byteOffset + * + * Holds the byte offset. + */ +uint QAttribute::byteOffset() const +{ + Q_D(const QAttribute); + return d->m_byteOffset; +} + +/*! + * \property QAttribute::divisor + * + * Holds the divisor. + */ +uint QAttribute::divisor() const +{ + Q_D(const QAttribute); + return d->m_divisor; +} + +/*! + * \property QAttribute::attributeType + * + * Holds the attribute type. + */ +QAttribute::AttributeType QAttribute::attributeType() const +{ + Q_D(const QAttribute); + return d->m_attributeType; +} + +void QAttribute::setBuffer(QBuffer *buffer) +{ + Q_D(QAttribute); + if (d->m_buffer == buffer) + return; + + if (d->m_buffer) + d->unregisterDestructionHelper(d->m_buffer); + + // We need to add it as a child of the current node if it has been declared inline + // Or not previously added as a child of the current node so that + // 1) The backend gets notified about it's creation + // 2) When the current node is destroyed, it gets destroyed as well + if (buffer && !buffer->parent()) + buffer->setParent(this); + + d->m_buffer = buffer; + + // Ensures proper bookkeeping + if (d->m_buffer) + d->registerDestructionHelper(d->m_buffer, &QAttribute::setBuffer, d->m_buffer); + + emit bufferChanged(buffer); +} + +void QAttribute::setName(const QString &name) +{ + Q_D(QAttribute); + if (d->m_name == name) + return; + + d->m_name = name; + emit nameChanged(name); +} + +void QAttribute::setVertexBaseType(VertexBaseType type) +{ + Q_D(QAttribute); + + if (d->m_vertexBaseType == type) + return; + + d->m_vertexBaseType = type; + emit vertexBaseTypeChanged(type); + emit dataTypeChanged(type); +} + +void QAttribute::setVertexSize(uint size) +{ + Q_D(QAttribute); + if (d->m_vertexSize == size) + return; + Q_ASSERT((size >= 1 && size <= 4) || (size == 9) || (size == 16)); + d->m_vertexSize = size; + emit vertexSizeChanged(size); + emit dataSizeChanged(size); +} + +void QAttribute::setCount(uint count) +{ + Q_D(QAttribute); + if (d->m_count == count) + return; + + d->m_count = count; + emit countChanged(count); +} + +void QAttribute::setByteStride(uint byteStride) +{ + Q_D(QAttribute); + if (d->m_byteStride == byteStride) + return; + + d->m_byteStride = byteStride; + emit byteStrideChanged(byteStride); +} + +void QAttribute::setByteOffset(uint byteOffset) +{ + Q_D(QAttribute); + if (d->m_byteOffset == byteOffset) + return; + + d->m_byteOffset = byteOffset; + emit byteOffsetChanged(byteOffset); +} + +void QAttribute::setDivisor(uint divisor) +{ + Q_D(QAttribute); + if (d->m_divisor == divisor) + return; + + d->m_divisor = divisor; + emit divisorChanged(divisor); +} + +void QAttribute::setAttributeType(AttributeType attributeType) +{ + Q_D(QAttribute); + if (d->m_attributeType == attributeType) + return; + + d->m_attributeType = attributeType; + emit attributeTypeChanged(attributeType); +} +/*! + * \brief QAttribute::defaultPositionAttributeName + * \return the name of the default position attribute + */ +QString QAttribute::defaultPositionAttributeName() +{ + return QStringLiteral("vertexPosition"); +} +/*! + * \brief QAttribute::defaultNormalAttributeName + * \return the name of the default normal attribute + */ +QString QAttribute::defaultNormalAttributeName() +{ + return QStringLiteral("vertexNormal"); +} +/*! + * \brief QAttribute::defaultColorAttributeName + * \return the name of the default color attribute + */ +QString QAttribute::defaultColorAttributeName() +{ + return QStringLiteral("vertexColor"); +} +/*! + * \brief QAttribute::defaultTextureCoordinateAttributeName + * \return the name of the default texture coordinate attribute + */ +QString QAttribute::defaultTextureCoordinateAttributeName() +{ + return QStringLiteral("vertexTexCoord"); +} +/*! + * \brief QAttribute::defaultTangentAttributeName + * \return the name of the default tangent attribute + */ +QString QAttribute::defaultTangentAttributeName() +{ + return QStringLiteral("vertexTangent"); +} + +/*! + * \brief QAttribute::defaultJointIndicesAttributeName + * \return the name of the default joint indices attribute + */ +QString QAttribute::defaultJointIndicesAttributeName() +{ + return QStringLiteral("vertexJointIndices"); +} + +/*! + * \brief QAttribute::defaultJointIndicesAttributeName + * \return the name of the default joint weights attribute + */ +QString QAttribute::defaultJointWeightsAttributeName() +{ + return QStringLiteral("vertexJointWeights"); +} + +/*! + * \brief QAttribute::defaultTextureCoordinate1AttributeName + * \return the name of the default attribute for the second layer of texture + * coordinates + */ +QString QAttribute::defaultTextureCoordinate1AttributeName() +{ + return QStringLiteral("vertexTexCoord1"); +} + +/*! + * \brief QAttribute::defaultTextureCoordinate2AttributeName + * \return the name of the default attribute for the third layer of texture + * coordinates + */ +QString QAttribute::defaultTextureCoordinate2AttributeName() +{ + return QStringLiteral("vertexTexCoord2"); +} + +/*! +\fn Qt3DCore::QAttribute::dataSizeChanged(uint vertexSize) + +The signal is emitted with \a vertexSize when the dataSize changes. +*/ +/*! +\fn Qt3DCore::QAttribute::dataTypeChanged(Qt3DCore::QAttribute::VertexBaseType vertexBaseType) + +The signal is emitted with \a vertexBaseType when the dataType changed. +*/ + +} // Qt3DCore + +QT_END_NAMESPACE diff --git a/src/core/geometry/qattribute.h b/src/core/geometry/qattribute.h new file mode 100644 index 000000000..aa0e5ce8b --- /dev/null +++ b/src/core/geometry/qattribute.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QATTRIBUTE_H +#define QT3DCORE_QATTRIBUTE_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QBuffer; +class QAttributePrivate; + +typedef QSharedPointer QBufferPtr; + +class Q_3DCORESHARED_EXPORT QAttribute : public QNode +{ + Q_OBJECT + Q_PROPERTY(Qt3DCore::QBuffer *buffer READ buffer WRITE setBuffer NOTIFY bufferChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(VertexBaseType vertexBaseType READ vertexBaseType WRITE setVertexBaseType NOTIFY vertexBaseTypeChanged) + Q_PROPERTY(uint vertexSize READ vertexSize WRITE setVertexSize NOTIFY vertexSizeChanged) + Q_PROPERTY(uint count READ count WRITE setCount NOTIFY countChanged) + Q_PROPERTY(uint byteStride READ byteStride WRITE setByteStride NOTIFY byteStrideChanged) + Q_PROPERTY(uint byteOffset READ byteOffset WRITE setByteOffset NOTIFY byteOffsetChanged) + Q_PROPERTY(uint divisor READ divisor WRITE setDivisor NOTIFY divisorChanged) + Q_PROPERTY(AttributeType attributeType READ attributeType WRITE setAttributeType NOTIFY attributeTypeChanged) + Q_PROPERTY(QString defaultPositionAttributeName READ defaultPositionAttributeName CONSTANT) + Q_PROPERTY(QString defaultNormalAttributeName READ defaultNormalAttributeName CONSTANT) + Q_PROPERTY(QString defaultColorAttributeName READ defaultColorAttributeName CONSTANT) + Q_PROPERTY(QString defaultTextureCoordinateAttributeName READ defaultTextureCoordinateAttributeName CONSTANT) + Q_PROPERTY(QString defaultTextureCoordinate1AttributeName READ defaultTextureCoordinate1AttributeName CONSTANT REVISION 11) + Q_PROPERTY(QString defaultTextureCoordinate2AttributeName READ defaultTextureCoordinate2AttributeName CONSTANT REVISION 11) + Q_PROPERTY(QString defaultTangentAttributeName READ defaultTangentAttributeName CONSTANT) + Q_PROPERTY(QString defaultJointIndicesAttributeName READ defaultJointIndicesAttributeName CONSTANT REVISION 10) + Q_PROPERTY(QString defaultJointWeightsAttributeName READ defaultJointWeightsAttributeName CONSTANT REVISION 10) + +public: + enum AttributeType { + VertexAttribute, + IndexAttribute, + DrawIndirectAttribute + }; + + Q_ENUM(AttributeType) // LCOV_EXCL_LINE + + enum VertexBaseType { + Byte = 0, + UnsignedByte, + Short, + UnsignedShort, + Int, + UnsignedInt, + HalfFloat, + Float, + Double + }; + Q_ENUM(VertexBaseType) // LCOV_EXCL_LINE + + explicit QAttribute(QNode *parent = nullptr); + explicit QAttribute(QBuffer *buf, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); + explicit QAttribute(QBuffer *buf, const QString &name, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); + ~QAttribute(); + + QBuffer *buffer() const; + QString name() const; + VertexBaseType vertexBaseType() const; + uint vertexSize() const; + uint count() const; + uint byteStride() const; + uint byteOffset() const; + uint divisor() const; + AttributeType attributeType() const; + + Q_INVOKABLE static QString defaultPositionAttributeName(); + Q_INVOKABLE static QString defaultNormalAttributeName(); + Q_INVOKABLE static QString defaultColorAttributeName(); + Q_INVOKABLE static QString defaultTextureCoordinateAttributeName(); + Q_INVOKABLE static QString defaultTangentAttributeName(); + static QString defaultJointIndicesAttributeName(); + static QString defaultJointWeightsAttributeName(); + static QString defaultTextureCoordinate1AttributeName(); + static QString defaultTextureCoordinate2AttributeName(); + +public Q_SLOTS: + void setBuffer(QBuffer *buffer); + void setName(const QString &name); + void setVertexBaseType(VertexBaseType type); + void setVertexSize(uint size); + void setCount(uint count); + void setByteStride(uint byteStride); + void setByteOffset(uint byteOffset); + void setDivisor(uint divisor); + void setAttributeType(AttributeType attributeType); + +Q_SIGNALS: + void bufferChanged(QBuffer *buffer); + void nameChanged(const QString &name); + void vertexBaseTypeChanged(VertexBaseType vertexBaseType); + void vertexSizeChanged(uint vertexSize); + void dataTypeChanged(VertexBaseType vertexBaseType); + void dataSizeChanged(uint vertexSize); + void countChanged(uint count); + void byteStrideChanged(uint byteStride); + void byteOffsetChanged(uint byteOffset); + void divisorChanged(uint divisor); + void attributeTypeChanged(AttributeType attributeType); + +private: + Q_DECLARE_PRIVATE(QAttribute) +}; + +} // Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QATTRIBUTE_H diff --git a/src/core/geometry/qattribute_p.h b/src/core/geometry/qattribute_p.h new file mode 100644 index 000000000..755a62207 --- /dev/null +++ b/src/core/geometry/qattribute_p.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QATTRIBUTE_P_H +#define QT3DCORE_QATTRIBUTE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QAttribute; + +class Q_3DCORE_PRIVATE_EXPORT QAttributePrivate : public Qt3DCore::QNodePrivate +{ +public: + Q_DECLARE_PUBLIC(QAttribute) + + QAttributePrivate(); + + QBuffer *m_buffer; + QString m_name; + QAttribute::VertexBaseType m_vertexBaseType; + uint m_vertexSize; + uint m_count; + uint m_byteStride; + uint m_byteOffset; + uint m_divisor; + QAttribute::AttributeType m_attributeType; +}; + +} // Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QATTRIBUTE_P_H diff --git a/src/core/geometry/qbuffer.cpp b/src/core/geometry/qbuffer.cpp new file mode 100644 index 000000000..1b0101c26 --- /dev/null +++ b/src/core/geometry/qbuffer.cpp @@ -0,0 +1,314 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbuffer.h" +#include "qbuffer_p.h" +#include + +QT_BEGIN_NAMESPACE + +using namespace Qt3DCore; + +namespace Qt3DCore { + +QBufferPrivate::QBufferPrivate() + : QNodePrivate() + , m_type(QBuffer::VertexBuffer) + , m_usage(QBuffer::StaticDraw) + , m_access(QBuffer::Write) +{ +} + +void QBufferPrivate::setData(const QByteArray &data) +{ + Q_Q(QBuffer); + const bool blocked = q->blockNotifications(true); + m_data = data; + emit q->dataChanged(data); + q->blockNotifications(blocked); +} + +/*! + * \qmltype Buffer + * \instantiates Qt3DCore::QBuffer + * \inqmlmodule Qt3D.Render + * + * \brief Provides a data store for raw data to later be used as vertices or + * uniforms. + */ + +/*! + * \qmlproperty QBuffer::UsageType Buffer::usage + * + * Holds the buffer usage. + */ + +/*! + * \qmlproperty QBuffer::BufferType Buffer::type + * + * Holds the buffer type. + * + * \deprecated + */ + +/*! + * \class Qt3DCore::QBuffer + * \inheaderfile Qt3DCore/QBuffer + * \inmodule Qt3DCore + * + * \inherits Qt3DCore::QNode + * + * \brief Provides a data store for raw data to later be used as vertices or + * uniforms. + * + * Data can be provided directly using QBuffer::setData(). + */ + +/*! + * \fn void Qt3DCore::QBuffer::dataChanged(const QByteArray &bytes) + * + * This signal is emitted with \a bytes when data changes. + */ + +/*! + * \fn void Qt3DCore::QBuffer::dataAvailable() + * + * This signal is emitted when data becomes available. + */ + +/*! + * \enum QBuffer::BufferType + * + * The type of the buffer. + * + * \value VertexBuffer + * GL_ARRAY_BUFFER + * \value IndexBuffer + * GL_ELEMENT_ARRAY_BUFFER + * \value PixelPackBuffer + * GL_PIXEL_PACK_BUFFER + * \value PixelUnpackBuffer + * GL_PIXEL_UNPACK_BUFFER + * \value UniformBuffer + * GL_UNIFORM_BUFFER + * \value ShaderStorageBuffer + * GL_SHADER_STORAGE_BUFFER + * \value DrawIndirectBuffer + * GL_DRAW_INDIRECT_BUFFER + * + * \deprecated + */ + +/*! + * \enum QBuffer::UsageType + * + * The type of the usage. + * + * \value StreamDraw + * GL_STREAM_DRAW + * \value StreamRead + * GL_STREAM_READ + * \value StreamCopy + * GL_STREAM_COPY + * \value StaticDraw + * GL_STATIC_DRAW + * \value StaticRead + * GL_STATIC_READ + * \value StaticCopy + * GL_STATIC_COPY + * \value DynamicDraw + * GL_DYNAMIC_DRAW + * \value DynamicRead + * GL_DYNAMIC_READ + * \value DynamicCopy + * GL_DYNAMIC_COPY + */ + +/*! + * \enum QBuffer::AccessType + * + * \value Write + * Write access + * \value Read + * Read access + * \value ReadWrite + * Write|Read + */ + +/*! + * \typedef Qt3DCore::QBufferDataGeneratorPtr + * \relates Qt3DCore::QBuffer + */ + +/*! + * Constructs a new QBuffer with \a parent. + */ +QBuffer::QBuffer(QNode *parent) + : QNode(*new QBufferPrivate(), parent) +{ +} + +/*! + * Constructs a new QBuffer of buffer type \a ty with \a parent. + * + * \deprecated + */ +QBuffer::QBuffer(QBuffer::BufferType ty, QNode *parent) + : QNode(*new QBufferPrivate(), parent) +{ + Q_D(QBuffer); + d->m_type = ty; +} + +/*! + * \internal + */ +QBuffer::~QBuffer() +{ +} + +/*! + * Sets \a bytes as data. + */ +void QBuffer::setData(const QByteArray &bytes) +{ + Q_D(QBuffer); + if (bytes != d->m_data) { + d->setData(bytes); + d->update(); + } +} + +/*! + * Updates the data by replacing it with \a bytes at \a offset. + */ +void QBuffer::updateData(int offset, const QByteArray &bytes) +{ + Q_D(QBuffer); + Q_ASSERT(offset >= 0 && (offset + bytes.size()) <= d->m_data.size()); + + // Update data + d->m_data.replace(offset, bytes.size(), bytes); + const bool blocked = blockNotifications(true); + emit dataChanged(d->m_data); + blockNotifications(blocked); + + QBufferUpdate updateData; + updateData.offset = offset; + updateData.data = bytes; + setProperty("QT3D_updateData", QVariant::fromValue(updateData)); + d->update(); +} + +/*! + * \return the data. + */ +QByteArray QBuffer::data() const +{ + Q_D(const QBuffer); + return d->m_data; +} + +/*! + * \property QBuffer::usage + * + * Holds the buffer usage. + */ +QBuffer::UsageType QBuffer::usage() const +{ + Q_D(const QBuffer); + return d->m_usage; +} + +void QBuffer::setUsage(QBuffer::UsageType usage) +{ + Q_D(QBuffer); + if (usage != d->m_usage) { + d->m_usage = usage; + emit usageChanged(usage); + } +} + +/*! + * \property QBuffer::type + * + * Holds the buffer type. + * + * \deprecated + */ +QBuffer::BufferType QBuffer::type() const +{ + Q_D(const QBuffer); + return d->m_type; +} + +void QBuffer::setAccessType(QBuffer::AccessType access) +{ + Q_D(QBuffer); + if (d->m_access != access) { + d->m_access = access; + Q_EMIT accessTypeChanged(access); + } +} + +/*! + * \property Qt3DCore::QBuffer::accessType + * + * Returns the \l {QBuffer::}{AccessType} of the buffer. + * + * \sa QBuffer::AccessType + */ +QBuffer::AccessType QBuffer::accessType() const +{ + Q_D(const QBuffer); + return d->m_access; +} + +void QBuffer::setType(QBuffer::BufferType type) +{ + Q_D(QBuffer); + if (type != d->m_type) { + d->m_type = type; + emit typeChanged(type); + } +} + +} // namespace Qt3DCore + +QT_END_NAMESPACE diff --git a/src/core/geometry/qbuffer.h b/src/core/geometry/qbuffer.h new file mode 100644 index 000000000..d60f99fa7 --- /dev/null +++ b/src/core/geometry/qbuffer.h @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QBUFFER_H +#define QT3DCORE_QBUFFER_H + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QBufferPrivate; + +class Q_3DCORESHARED_EXPORT QBuffer : public Qt3DCore::QNode +{ + Q_OBJECT + Q_PROPERTY(BufferType type READ type WRITE setType NOTIFY typeChanged) + Q_PROPERTY(UsageType usage READ usage WRITE setUsage NOTIFY usageChanged) + Q_PROPERTY(AccessType accessType READ accessType WRITE setAccessType NOTIFY accessTypeChanged REVISION 9) + +public: + enum BufferType + { + VertexBuffer = 0x8892, // GL_ARRAY_BUFFER + IndexBuffer = 0x8893, // GL_ELEMENT_ARRAY_BUFFER + PixelPackBuffer = 0x88EB, // GL_PIXEL_PACK_BUFFER + PixelUnpackBuffer = 0x88EC, // GL_PIXEL_UNPACK_BUFFER + UniformBuffer = 0x8A11, // GL_UNIFORM_BUFFER + ShaderStorageBuffer = 0x90D2, // GL_SHADER_STORAGE_BUFFER + DrawIndirectBuffer = 0x8F3F // GL_DRAW_INDIRECT_BUFFER + }; + Q_ENUM(BufferType) // LCOV_EXCL_LINE + + enum UsageType + { + StreamDraw = 0x88E0, // GL_STREAM_DRAW + StreamRead = 0x88E1, // GL_STREAM_READ + StreamCopy = 0x88E2, // GL_STREAM_COPY + StaticDraw = 0x88E4, // GL_STATIC_DRAW + StaticRead = 0x88E5, // GL_STATIC_READ + StaticCopy = 0x88E6, // GL_STATIC_COPY + DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW + DynamicRead = 0x88E9, // GL_DYNAMIC_READ + DynamicCopy = 0x88EA // GL_DYNAMIC_COPY + }; + Q_ENUM(UsageType) // LCOV_EXCL_LINE + + enum AccessType { + Write = 0x1, + Read = 0x2, + ReadWrite = Write|Read + }; + Q_ENUM(AccessType) // LCOV_EXCL_LINE + + explicit QBuffer(Qt3DCore::QNode *parent = nullptr); + QT_DEPRECATED explicit QBuffer(BufferType ty, Qt3DCore::QNode *parent = nullptr); + ~QBuffer(); + + UsageType usage() const; + QT_DEPRECATED BufferType type() const; + AccessType accessType() const; + + void setData(const QByteArray &bytes); + QByteArray data() const; + + Q_INVOKABLE void updateData(int offset, const QByteArray &bytes); + +public Q_SLOTS: + QT_DEPRECATED void setType(BufferType type); + void setUsage(UsageType usage); + void setAccessType(AccessType access); + +Q_SIGNALS: + void dataChanged(const QByteArray &bytes); + void typeChanged(BufferType type); + void usageChanged(UsageType usage); + void accessTypeChanged(AccessType access); + void dataAvailable(); + +private: + Q_DECLARE_PRIVATE(QBuffer) +}; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QBUFFER_H diff --git a/src/core/geometry/qbuffer_p.h b/src/core/geometry/qbuffer_p.h new file mode 100644 index 000000000..c4bb9d834 --- /dev/null +++ b/src/core/geometry/qbuffer_p.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QBUFFER_P_H +#define QT3DCORE_QBUFFER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class Q_3DCORESHARED_EXPORT QBufferPrivate : public Qt3DCore::QNodePrivate +{ +public: + Q_DECLARE_PUBLIC(QBuffer) + + QBufferPrivate(); + + QByteArray m_data; + QBuffer::BufferType m_type; + QBuffer::UsageType m_usage; + QBuffer::AccessType m_access; + + void setData(const QByteArray &data); +}; + +struct QBufferUpdate +{ + int offset; + QByteArray data; +}; + +} // namespace Qt3DCore + +QT_END_NAMESPACE +Q_DECLARE_METATYPE(Qt3DCore::QBufferUpdate) // LCOV_EXCL_LINE + +#endif // QT3DCORE_QBUFFER_P_H diff --git a/src/core/geometry/qgeometry.cpp b/src/core/geometry/qgeometry.cpp new file mode 100644 index 000000000..008ad4b3d --- /dev/null +++ b/src/core/geometry/qgeometry.cpp @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgeometry.h" +#include "qgeometryfactory_p.h" +#include "qgeometry_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +using namespace Qt3DCore; + +QGeometryFactory::~QGeometryFactory() +{ +} + +QGeometryPrivate::QGeometryPrivate() + : QNodePrivate(), + m_boundingVolumePositionAttribute(nullptr) +{ +} + +QGeometryPrivate::~QGeometryPrivate() +{ +} + +void QGeometryPrivate::setExtent(const QVector3D &minExtent, const QVector3D &maxExtent) +{ + Q_Q(QGeometry); + if (m_minExtent != minExtent) { + m_minExtent = minExtent; + emit q->minExtentChanged(minExtent); + } + + if (m_maxExtent != maxExtent) { + m_maxExtent = maxExtent; + emit q->maxExtentChanged(maxExtent); + } +} + +/*! + \qmltype Geometry + \instantiates Qt3DCore::QGeometry + \inqmlmodule Qt3D.Core + \inherits Node + \since 5.7 + \brief Encapsulates geometry. + + A Geometry type is used to group a list of Attribute objects together + to form a geometric shape Qt3D is able to render using GeometryRenderer. + Special attribute can be set in order to calculate bounding volume of the shape. + */ + +/*! + \class Qt3DCore::QGeometry + \inmodule Qt3DCore + \since 5.7 + \brief Encapsulates geometry. + + A Qt3DCore::QGeometry class is used to group a list of Qt3DCore::QAttribute + objects together to form a geometric shape Qt3D is able to render using + Qt3DCore::QGeometryRenderer. Special attribute can be set in order to calculate + bounding volume of the shape. + */ + +/*! + \qmlproperty Attribute Geometry::boundingVolumePositionAttribute + + Holds the attribute used to compute the bounding volume. The bounding volume is used internally + for picking and view frustum culling. + + If unspecified, the system will look for the attribute using the name returned by + QAttribute::defaultPositionAttributeName. + + \sa Attribute + */ +/*! + \qmlproperty list Geometry::attributes + + Holds the list of attributes the geometry comprises of. + */ + +/*! + \property QGeometry::boundingVolumePositionAttribute + + Holds the attribute used to compute the bounding volume. The bounding volume is used internally + for picking and view frustum culling. + + If unspecified, the system will look for the attribute using the name returned by + QAttribute::defaultPositionAttributeName. + + \sa Qt3DCore::QAttribute + */ + + +/*! + Constructs a new QGeometry with \a parent. + */ +QGeometry::QGeometry(QNode *parent) + : QGeometry(*new QGeometryPrivate(), parent) {} + +/*! + \fn Qt3DCore::QGeometryFactory::operator()() + + Returns the generated geometry. +*/ +/*! + \fn bool Qt3DCore::QGeometryFactory::operator==(const QGeometryFactory &other) const = 0 + + Compares the factory with the factory specified in \a other. + Returns true if they are equal. +*/ +/*! + \internal + */ +QGeometry::~QGeometry() +{ +} + +/*! + \internal + */ +QGeometry::QGeometry(QGeometryPrivate &dd, QNode *parent) + : QNode(dd, parent) +{ +} + +/*! + \fn void Qt3DCore::QGeometry::addAttribute(Qt3DCore::QAttribute *attribute) + Adds an \a attribute to this geometry. + */ +void QGeometry::addAttribute(QAttribute *attribute) +{ + Q_ASSERT(attribute); + Q_D(QGeometry); + if (!d->m_attributes.contains(attribute)) { + d->m_attributes.append(attribute); + + // Ensures proper bookkeeping + d->registerDestructionHelper(attribute, &QGeometry::removeAttribute, d->m_attributes); + + // We need to add it as a child of the current node if it has been declared inline + // Or not previously added as a child of the current node so that + // 1) The backend gets notified about it's creation + // 2) When the current node is destroyed, it gets destroyed as well + if (!attribute->parent()) + attribute->setParent(this); + + d->update(); + } +} + +/*! + \fn void Qt3DCore::QGeometry::removeAttribute(Qt3DCore::QAttribute *attribute) + Removes the given \a attribute from this geometry. + */ +void QGeometry::removeAttribute(QAttribute *attribute) +{ + Q_ASSERT(attribute); + Q_D(QGeometry); + d->m_attributes.removeOne(attribute); + // Remove bookkeeping connection + d->unregisterDestructionHelper(attribute); + d->update(); +} + +void QGeometry::setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute) +{ + Q_D(QGeometry); + if (d->m_boundingVolumePositionAttribute != boundingVolumePositionAttribute) { + d->m_boundingVolumePositionAttribute = boundingVolumePositionAttribute; + emit boundingVolumePositionAttributeChanged(boundingVolumePositionAttribute); + } +} + +QAttribute *QGeometry::boundingVolumePositionAttribute() const +{ + Q_D(const QGeometry); + return d->m_boundingVolumePositionAttribute; +} + +/*! + \qmlproperty vector3d Geometry::minExtent + + Holds the vertex with the lowest x, y, z position values. + */ + +/*! + \property QGeometry::minExtent + + Holds the vertex with the lowest x, y, z position values. + */ +QVector3D QGeometry::minExtent() const +{ + Q_D(const QGeometry); + return d->m_minExtent; +} + +/*! + \qmlproperty vector3d Geometry::maxExtent + + Holds the vertex with the highest x, y, z position values. + */ + +/*! + \property QGeometry::maxExtent + + Holds the vertex with the highest x, y, z position values. + */ +QVector3D QGeometry::maxExtent() const +{ + Q_D(const QGeometry); + return d->m_maxExtent; +} + +/*! + Returns the list of attributes in this geometry. + */ +QVector QGeometry::attributes() const +{ + Q_D(const QGeometry); + return d->m_attributes; +} + +QT_END_NAMESPACE + +#include "moc_qgeometry.cpp" diff --git a/src/core/geometry/qgeometry.h b/src/core/geometry/qgeometry.h new file mode 100644 index 000000000..a619884a0 --- /dev/null +++ b/src/core/geometry/qgeometry.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QGEOMETRY_H +#define QT3DCORE_QGEOMETRY_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QAttribute; +class QGeometryPrivate; + +class Q_3DCORESHARED_EXPORT QGeometry : public Qt3DCore::QNode +{ + Q_OBJECT + Q_PROPERTY(Qt3DCore::QAttribute *boundingVolumePositionAttribute READ boundingVolumePositionAttribute WRITE setBoundingVolumePositionAttribute NOTIFY boundingVolumePositionAttributeChanged) + Q_PROPERTY(QVector3D minExtent READ minExtent NOTIFY minExtentChanged REVISION 13) + Q_PROPERTY(QVector3D maxExtent READ maxExtent NOTIFY maxExtentChanged REVISION 13) +public: + explicit QGeometry(Qt3DCore::QNode *parent = nullptr); + ~QGeometry(); + + QVector attributes() const; + Q_INVOKABLE void addAttribute(Qt3DCore::QAttribute *attribute); + Q_INVOKABLE void removeAttribute(Qt3DCore::QAttribute *attribute); + + QAttribute *boundingVolumePositionAttribute() const; + QVector3D minExtent() const; + QVector3D maxExtent() const; + +public Q_SLOTS: + void setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute); + +Q_SIGNALS: + void boundingVolumePositionAttributeChanged(QAttribute *boundingVolumePositionAttribute); + Q_REVISION(13) void minExtentChanged(const QVector3D &minExtent); + Q_REVISION(13) void maxExtentChanged(const QVector3D &maxExtent); +protected: + explicit QGeometry(QGeometryPrivate &dd, Qt3DCore::QNode *parent = nullptr); + +private: + Q_DECLARE_PRIVATE(QGeometry) +}; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QGEOMETRY_H diff --git a/src/core/geometry/qgeometry_p.h b/src/core/geometry/qgeometry_p.h new file mode 100644 index 000000000..467131fbe --- /dev/null +++ b/src/core/geometry/qgeometry_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QGEOMETRY_P_H +#define QT3DCORE_QGEOMETRY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QAttribute; + +class Q_3DCORESHARED_EXPORT QGeometryPrivate : public QNodePrivate +{ +public: + Q_DECLARE_PUBLIC(QGeometry) + QGeometryPrivate(); + ~QGeometryPrivate(); + + void setExtent(const QVector3D &minExtent, const QVector3D &maxExtent); + + + QVector m_attributes; + QAttribute *m_boundingVolumePositionAttribute; + QVector3D m_minExtent; + QVector3D m_maxExtent; +}; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QGEOMETRY_P_H + diff --git a/src/core/geometry/qgeometryfactory_p.h b/src/core/geometry/qgeometryfactory_p.h new file mode 100644 index 000000000..47f3a5281 --- /dev/null +++ b/src/core/geometry/qgeometryfactory_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QGEOMETRYFACTORY_P_H +#define QT3DCORE_QGEOMETRYFACTORY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QGeometry; + +class Q_3DCORESHARED_EXPORT QGeometryFactory : public QAbstractFunctor +{ +public: + virtual ~QGeometryFactory(); + virtual QGeometry *operator()() = 0; + virtual bool operator ==(const QGeometryFactory &other) const = 0; +}; + +typedef QSharedPointer QGeometryFactoryPtr; + +} // namespace Qt3DRender + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Qt3DCore::QGeometryFactoryPtr) // LCOV_EXCL_LINE + +#endif // QT3DCORE_QGEOMETRYFACTORY_P_H diff --git a/src/core/qurlhelper.cpp b/src/core/qurlhelper.cpp new file mode 100644 index 000000000..1660714c9 --- /dev/null +++ b/src/core/qurlhelper.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qurlhelper_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +QString QUrlHelper::urlToLocalFileOrQrc(const QUrl &url) +{ + const QString scheme(url.scheme().toLower()); + if (scheme == QLatin1String("qrc")) { + if (url.authority().isEmpty()) + return QLatin1Char(':') + url.path(); + return QString(); + } + +#if defined(Q_OS_ANDROID) + if (scheme == QLatin1String("assets")) { + if (url.authority().isEmpty()) + return url.toString(); + return QString(); + } +#endif + + return url.toLocalFile(); +} + +} // Qt3DCore + +QT_END_NAMESPACE diff --git a/src/core/qurlhelper_p.h b/src/core/qurlhelper_p.h new file mode 100644 index 000000000..b545ece12 --- /dev/null +++ b/src/core/qurlhelper_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QURLHELPER_P_H +#define QT3DCORE_QURLHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class Q_3DCORESHARED_EXPORT QUrlHelper +{ +public: + static QString urlToLocalFileOrQrc(const QUrl &url); +}; + +} // Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QURLHELPER_P_H diff --git a/src/doc/src/qt3drender-geometry.qdoc b/src/doc/src/qt3drender-geometry.qdoc index 905d76eef..6bfabbc76 100644 --- a/src/doc/src/qt3drender-geometry.qdoc +++ b/src/doc/src/qt3drender-geometry.qdoc @@ -44,8 +44,8 @@ \section2 Buffer - The Qt3DRender::QBuffer class stores the raw data. This acts purely as an - array of memory. In most cases a Qt3DRender::QBuffer will be used + The Qt3DCore::QBuffer class stores the raw data. This acts purely as an + array of memory. In most cases a Qt3DCore::QBuffer will be used indirectly by being referenced by one or more Qt3DRender::QAttributes. However there are times when a QBuffer may be used directly as the value property of a QParameter when dealing with Uniform Buffer Objects (UBO) or @@ -61,9 +61,9 @@ \section2 Attribute - Qt3DRender::QAttribute specifies how data contained in the referenced + Qt3DCore::QAttribute specifies how data contained in the referenced buffer should be extracted and passed to an input of a vertex shader. It - references a Qt3DRender::QBuffer and can specify the layout of the + references a Qt3DCore::QBuffer and can specify the layout of the attributes by definining the vertex size, the data type, the stride between two vertices and a starting offset. The type of the attribute will also define whether it is to be used as a vertex buffer or as an index buffer. @@ -87,7 +87,7 @@ \section2 Geometry - A Qt3DRender::QGeometry aggregates various attributes to form a piece of + A Qt3DCore::QGeometry aggregates various attributes to form a piece of geometry. Usually a proper geometry will provide an attribute for vertex positions, an attribute for vertex normals and an attribute for texture coordinates. If you want your geometry to also work with normal mapped @@ -122,7 +122,7 @@ \section2 GeometryRenderer Qt3DRender::QGeometryRenderer is a QComponent which when aggregated by a - QEntity allows to draw the Qt3DRender::QGeometry it references. It provides + QEntity allows to draw the Qt3DCore::QGeometry it references. It provides properties to control the draw call such as the number of instances to be drawn, the starting instance, the type of Qt3DRender::QGeometryRenderer::PrimitiveType to be used, etc. A diff --git a/src/extras/3dtext/qextrudedtextgeometry.cpp b/src/extras/3dtext/qextrudedtextgeometry.cpp index 3c4580c65..67f3b21ce 100644 --- a/src/extras/3dtext/qextrudedtextgeometry.cpp +++ b/src/extras/3dtext/qextrudedtextgeometry.cpp @@ -50,8 +50,8 @@ #include "qextrudedtextgeometry.h" #include "qextrudedtextgeometry_p.h" -#include -#include +#include +#include #include #include #include @@ -162,35 +162,35 @@ QExtrudedTextGeometryPrivate::QExtrudedTextGeometryPrivate() void QExtrudedTextGeometryPrivate::init() { Q_Q(QExtrudedTextGeometry); - m_positionAttribute = new Qt3DRender::QAttribute(q); - m_normalAttribute = new Qt3DRender::QAttribute(q); - m_indexAttribute = new Qt3DRender::QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_positionAttribute = new Qt3DCore::QAttribute(q); + m_normalAttribute = new Qt3DCore::QAttribute(q); + m_indexAttribute = new Qt3DCore::QAttribute(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); const quint32 elementSize = 3 + 3; const quint32 stride = elementSize * sizeof(float); - m_positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - m_positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + m_positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + m_positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); m_positionAttribute->setVertexSize(3); - m_positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + m_positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); m_positionAttribute->setBuffer(m_vertexBuffer); m_positionAttribute->setByteStride(stride); m_positionAttribute->setByteOffset(0); m_positionAttribute->setCount(0); - m_normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); - m_normalAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + m_normalAttribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName()); + m_normalAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); m_normalAttribute->setVertexSize(3); - m_normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + m_normalAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); m_normalAttribute->setBuffer(m_vertexBuffer); m_normalAttribute->setByteStride(stride); m_normalAttribute->setByteOffset(3 * sizeof(float)); m_normalAttribute->setCount(0); - m_indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); - m_indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + m_indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); + m_indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); m_indexAttribute->setBuffer(m_indexBuffer); m_indexAttribute->setCount(0); @@ -255,7 +255,7 @@ void QExtrudedTextGeometryPrivate::init() * in 3D space. * \since 5.9 * \ingroup geometries - * \inherits Qt3DRender::QGeometry + * \inherits Qt3DCore::QGeometry * * The QExtrudedTextGeometry class is most commonly used internally by the QText3DMesh * but can also be used in custom Qt3DRender::QGeometryRenderer subclasses. @@ -469,7 +469,7 @@ float QExtrudedTextGeometry::extrusionLength() const * * Holds the geometry position attribute. */ -Qt3DRender::QAttribute *QExtrudedTextGeometry::positionAttribute() const +Qt3DCore::QAttribute *QExtrudedTextGeometry::positionAttribute() const { Q_D(const QExtrudedTextGeometry); return d->m_positionAttribute; @@ -480,7 +480,7 @@ Qt3DRender::QAttribute *QExtrudedTextGeometry::positionAttribute() const * * Holds the geometry normal attribute. */ -Qt3DRender::QAttribute *QExtrudedTextGeometry::normalAttribute() const +Qt3DCore::QAttribute *QExtrudedTextGeometry::normalAttribute() const { Q_D(const QExtrudedTextGeometry); return d->m_normalAttribute; @@ -491,7 +491,7 @@ Qt3DRender::QAttribute *QExtrudedTextGeometry::normalAttribute() const * * Holds the geometry index attribute. */ -Qt3DRender::QAttribute *QExtrudedTextGeometry::indexAttribute() const +Qt3DCore::QAttribute *QExtrudedTextGeometry::indexAttribute() const { Q_D(const QExtrudedTextGeometry); return d->m_indexAttribute; diff --git a/src/extras/3dtext/qextrudedtextgeometry.h b/src/extras/3dtext/qextrudedtextgeometry.h index d40797c6f..0a92932af 100644 --- a/src/extras/3dtext/qextrudedtextgeometry.h +++ b/src/extras/3dtext/qextrudedtextgeometry.h @@ -52,39 +52,39 @@ #define QT3DEXTRAS_QEXTRUDEDTEXTGEOMETRY_H #include -#include +#include #include #include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; -} // namespace Qt3DRender +} // namespace Qt3DCore namespace Qt3DExtras { class QExtrudedTextGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QExtrudedTextGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QExtrudedTextGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) Q_PROPERTY(float extrusionLength READ extrusionLength WRITE setDepth NOTIFY depthChanged) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QExtrudedTextGeometry(Qt3DCore::QNode *parent = nullptr); ~QExtrudedTextGeometry(); - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; QString text() const; QFont font() const; float extrusionLength() const; diff --git a/src/extras/3dtext/qextrudedtextgeometry_p.h b/src/extras/3dtext/qextrudedtextgeometry_p.h index 0bfa45e17..22b9e39ea 100644 --- a/src/extras/3dtext/qextrudedtextgeometry_p.h +++ b/src/extras/3dtext/qextrudedtextgeometry_p.h @@ -62,23 +62,24 @@ // We mean it. // -#include +#include +#include #include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // namespace Qt3DRender +} // namespace Qt3DCore namespace Qt3DExtras { class QExtrudedTextGeometry; -class QExtrudedTextGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QExtrudedTextGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QExtrudedTextGeometryPrivate(); @@ -90,11 +91,11 @@ public: float m_depth; float m_edgeSplitAngle; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; Q_DECLARE_PUBLIC(QExtrudedTextGeometry) }; diff --git a/src/extras/geometries/qconegeometry.cpp b/src/extras/geometries/qconegeometry.cpp index af9941394..e2165e6f8 100644 --- a/src/extras/geometries/qconegeometry.cpp +++ b/src/extras/geometries/qconegeometry.cpp @@ -45,7 +45,7 @@ * \brief The QConeGeometry class allows creation of a cone in 3D space. * \since 5.7 * \ingroup geometries - * \inherits Qt3DRender::QGeometry + * \inherits Qt3DCore::QGeometry * * The QConeGeometry class is most commonly used internally by the QConeMesh * but can also be used in custom Qt3DRender::QGeometryRenderer subclasses. The class @@ -59,15 +59,15 @@ #include "qconegeometry.h" #include "qconegeometry_p.h" -#include -#include +#include +#include #include #include QT_BEGIN_NAMESPACE -using namespace Qt3DRender; +using namespace Qt3DCore; namespace Qt3DExtras { @@ -249,8 +249,8 @@ void QConeGeometryPrivate::init() m_normalAttribute = new QAttribute(q); m_texCoordAttribute = new QAttribute(q); m_indexAttribute = new QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); // vec3 pos, vec2 tex, vec3 normal const quint32 elementSize = 3 + 2 + 3; diff --git a/src/extras/geometries/qconegeometry.h b/src/extras/geometries/qconegeometry.h index 2deb56f0e..cff40576e 100644 --- a/src/extras/geometries/qconegeometry.h +++ b/src/extras/geometries/qconegeometry.h @@ -41,11 +41,11 @@ #define QT3DEXTRAS_QCONEGEOMETRY_H #include -#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; } // Render @@ -53,7 +53,7 @@ namespace Qt3DExtras { class QConeGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QConeGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QConeGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY( bool hasTopEndcap READ hasTopEndcap WRITE setHasTopEndcap NOTIFY hasTopEndcapChanged ) @@ -63,10 +63,10 @@ class Q_3DEXTRASSHARED_EXPORT QConeGeometry : public Qt3DRender::QGeometry Q_PROPERTY( float topRadius READ topRadius WRITE setTopRadius NOTIFY topRadiusChanged ) Q_PROPERTY( float bottomRadius READ bottomRadius WRITE setBottomRadius NOTIFY bottomRadiusChanged ) Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QConeGeometry(QNode *parent = nullptr); @@ -83,10 +83,10 @@ public: int slices() const; float length() const; - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *texCoordAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *texCoordAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; public Q_SLOTS: void setHasTopEndcap( bool hasTopEndcap ); diff --git a/src/extras/geometries/qconegeometry_p.h b/src/extras/geometries/qconegeometry_p.h index 39c3913fc..a87aa41c6 100644 --- a/src/extras/geometries/qconegeometry_p.h +++ b/src/extras/geometries/qconegeometry_p.h @@ -51,20 +51,20 @@ // We mean it. // -#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // namespace Qt3DRender +} // namespace Qt3DCore namespace Qt3DExtras { -class QConeGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QConeGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QConeGeometryPrivate(); @@ -80,13 +80,13 @@ public: float m_topRadius; float m_bottomRadius; float m_length; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_texCoordAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_positionBuffer; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_texCoordAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_positionBuffer; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; QByteArray generateVertexData() const; QByteArray generateIndexData() const; diff --git a/src/extras/geometries/qconemesh.cpp b/src/extras/geometries/qconemesh.cpp index d54e43e1f..508e7cfd3 100644 --- a/src/extras/geometries/qconemesh.cpp +++ b/src/extras/geometries/qconemesh.cpp @@ -44,8 +44,8 @@ #include "qconegeometry.h" #include -#include -#include +#include +#include #include #include diff --git a/src/extras/geometries/qconemesh.h b/src/extras/geometries/qconemesh.h index 6c0408b7b..57fe0c0fc 100644 --- a/src/extras/geometries/qconemesh.h +++ b/src/extras/geometries/qconemesh.h @@ -97,7 +97,7 @@ private: void setFirstInstance(int firstInstance); void setRestartIndexValue(int index); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(Qt3DRender::QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); }; diff --git a/src/extras/geometries/qcuboidgeometry.cpp b/src/extras/geometries/qcuboidgeometry.cpp index 1f86defb4..87707eefd 100644 --- a/src/extras/geometries/qcuboidgeometry.cpp +++ b/src/extras/geometries/qcuboidgeometry.cpp @@ -40,16 +40,16 @@ #include "qcuboidgeometry.h" #include "qcuboidgeometry_p.h" -#include -#include -#include +#include +#include +#include #include QT_BEGIN_NAMESPACE -using namespace Qt3DRender; +using namespace Qt3DCore; namespace Qt3DExtras { @@ -406,13 +406,13 @@ QCuboidGeometryPrivate::QCuboidGeometryPrivate() void QCuboidGeometryPrivate::init() { Q_Q(QCuboidGeometry); - m_positionAttribute = new Qt3DRender::QAttribute(q); - m_normalAttribute = new Qt3DRender::QAttribute(q); - m_texCoordAttribute = new Qt3DRender::QAttribute(q); - m_tangentAttribute = new Qt3DRender::QAttribute(q); - m_indexAttribute = new Qt3DRender::QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_positionAttribute = new Qt3DCore::QAttribute(q); + m_normalAttribute = new Qt3DCore::QAttribute(q); + m_texCoordAttribute = new Qt3DCore::QAttribute(q); + m_tangentAttribute = new Qt3DCore::QAttribute(q); + m_indexAttribute = new Qt3DCore::QAttribute(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); // vec3 pos vec2 tex vec3 normal vec4 tangent const quint32 stride = (3 + 2 + 3 + 4) * sizeof(float); @@ -578,7 +578,7 @@ QByteArray QCuboidGeometryPrivate::generateIndexData() const * \brief The QCuboidGeometry class allows creation of a cuboid in 3D space. * \since 5.7 * \ingroup geometries - * \inherits Qt3DRender::QGeometry + * \inherits Qt3DCore::QGeometry * * The QCuboidGeometry class is most commonly used internally by the QCuboidMesh * but can also be used in custom Qt3DRender::QGeometryRenderer subclasses. diff --git a/src/extras/geometries/qcuboidgeometry.h b/src/extras/geometries/qcuboidgeometry.h index 50bb10930..1234c65be 100644 --- a/src/extras/geometries/qcuboidgeometry.h +++ b/src/extras/geometries/qcuboidgeometry.h @@ -41,22 +41,22 @@ #define QT3DEXTRAS_QCUBOIDGEOMETRY_H #include -#include +#include #include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { class QCuboidGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QCuboidGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QCuboidGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY(float xExtent READ xExtent WRITE setXExtent NOTIFY xExtentChanged) @@ -65,11 +65,11 @@ class Q_3DEXTRASSHARED_EXPORT QCuboidGeometry : public Qt3DRender::QGeometry Q_PROPERTY(QSize xyMeshResolution READ xyMeshResolution WRITE setXYMeshResolution NOTIFY xyMeshResolutionChanged) Q_PROPERTY(QSize yzMeshResolution READ yzMeshResolution WRITE setYZMeshResolution NOTIFY yzMeshResolutionChanged) Q_PROPERTY(QSize xzMeshResolution READ xzMeshResolution WRITE setXZMeshResolution NOTIFY xzMeshResolutionChanged) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *tangentAttribute READ tangentAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *tangentAttribute READ tangentAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QCuboidGeometry(QNode *parent = nullptr); @@ -85,11 +85,11 @@ public: QSize xyMeshResolution() const; QSize xzMeshResolution() const; - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *texCoordAttribute() const; - Qt3DRender::QAttribute *tangentAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *texCoordAttribute() const; + Qt3DCore::QAttribute *tangentAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; public Q_SLOTS: void setXExtent(float xExtent); diff --git a/src/extras/geometries/qcuboidgeometry_p.h b/src/extras/geometries/qcuboidgeometry_p.h index 2c0ea5524..399ea5876 100644 --- a/src/extras/geometries/qcuboidgeometry_p.h +++ b/src/extras/geometries/qcuboidgeometry_p.h @@ -53,20 +53,21 @@ #include -#include +#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { -class QCuboidGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QCuboidGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QCuboidGeometryPrivate(); @@ -82,13 +83,13 @@ public: QSize m_xzFaceResolution; QSize m_xyFaceResolution; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_texCoordAttribute; - Qt3DRender::QAttribute *m_tangentAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_texCoordAttribute; + Qt3DCore::QAttribute *m_tangentAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; Q_DECLARE_PUBLIC(QCuboidGeometry) diff --git a/src/extras/geometries/qcuboidmesh.h b/src/extras/geometries/qcuboidmesh.h index dc7f821ff..a945dbe2b 100644 --- a/src/extras/geometries/qcuboidmesh.h +++ b/src/extras/geometries/qcuboidmesh.h @@ -97,7 +97,7 @@ private: void setFirstInstance(int firstInstance); void setRestartIndexValue(int index); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(Qt3DRender::QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); }; diff --git a/src/extras/geometries/qcylindergeometry.cpp b/src/extras/geometries/qcylindergeometry.cpp index a6bdc5f8d..5d37b5ac8 100644 --- a/src/extras/geometries/qcylindergeometry.cpp +++ b/src/extras/geometries/qcylindergeometry.cpp @@ -44,8 +44,8 @@ #include "qcylindergeometry.h" #include "qcylindergeometry_p.h" -#include -#include +#include +#include #include #include @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -using namespace Qt3DRender; +using namespace Qt3DCore; namespace Qt3DExtras { @@ -202,8 +202,8 @@ void QCylinderGeometryPrivate::init() m_normalAttribute = new QAttribute(q); m_texCoordAttribute = new QAttribute(q); m_indexAttribute = new QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); // vec3 pos, vec2 tex, vec3 normal const quint32 elementSize = 3 + 2 + 3; @@ -354,7 +354,7 @@ QByteArray QCylinderGeometryPrivate::generateIndexData() const * \brief The QCylinderGeometry class allows creation of a cylinder in 3D space. * \since 5.7 * \ingroup geometries - * \inherits Qt3DRender::QGeometry + * \inherits Qt3DCore::QGeometry * * The QCylinderGeometry class is most commonly used internally by the QCylinderMesh * but can also be used in custom Qt3DRender::QGeometryRenderer subclasses. diff --git a/src/extras/geometries/qcylindergeometry.h b/src/extras/geometries/qcylindergeometry.h index 0a9022016..4151aadb2 100644 --- a/src/extras/geometries/qcylindergeometry.h +++ b/src/extras/geometries/qcylindergeometry.h @@ -41,30 +41,30 @@ #define QT3DEXTRAS_QCYLINDERGEOMETRY_H #include -#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; -} // namespace Qt3DRender +} // namespace Qt3DCore namespace Qt3DExtras { class QCylinderGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QCylinderGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QCylinderGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QCylinderGeometry(QNode *parent = nullptr); @@ -78,10 +78,10 @@ public: float radius() const; float length() const; - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *texCoordAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *texCoordAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; public Q_SLOTS: void setRings(int rings); diff --git a/src/extras/geometries/qcylindergeometry_p.h b/src/extras/geometries/qcylindergeometry_p.h index d88c34874..4803322e1 100644 --- a/src/extras/geometries/qcylindergeometry_p.h +++ b/src/extras/geometries/qcylindergeometry_p.h @@ -51,20 +51,21 @@ // We mean it. // -#include +#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // namespace Qt3DRender +} // namespace Qt3DCore namespace Qt3DExtras { -class QCylinderGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QCylinderGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QCylinderGeometryPrivate(); @@ -77,12 +78,12 @@ public: int m_slices; float m_radius; float m_length; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_texCoordAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_texCoordAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; QByteArray generateVertexData() const; QByteArray generateIndexData() const; diff --git a/src/extras/geometries/qcylindermesh.cpp b/src/extras/geometries/qcylindermesh.cpp index 48e114cd4..3a495cce2 100644 --- a/src/extras/geometries/qcylindermesh.cpp +++ b/src/extras/geometries/qcylindermesh.cpp @@ -45,14 +45,15 @@ #include "qcylindermesh.h" #include -#include -#include +#include +#include #include #include QT_BEGIN_NAMESPACE +using namespace Qt3DCore; using namespace Qt3DRender; namespace Qt3DExtras { diff --git a/src/extras/geometries/qcylindermesh.h b/src/extras/geometries/qcylindermesh.h index 19ef5d2cf..f2c8fb01b 100644 --- a/src/extras/geometries/qcylindermesh.h +++ b/src/extras/geometries/qcylindermesh.h @@ -86,11 +86,11 @@ private: void setFirstInstance(int firstInstance); void setRestartIndexValue(int index); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(Qt3DRender::QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); }; -} // namespace Qt3DRender +} // namespace Qt3DExtras QT_END_NAMESPACE diff --git a/src/extras/geometries/qplanegeometry.cpp b/src/extras/geometries/qplanegeometry.cpp index a7ba3d56a..e83548ad5 100644 --- a/src/extras/geometries/qplanegeometry.cpp +++ b/src/extras/geometries/qplanegeometry.cpp @@ -40,14 +40,14 @@ #include "qplanegeometry.h" #include "qplanegeometry_p.h" -#include -#include +#include +#include #include QT_BEGIN_NAMESPACE -using namespace Qt3DRender; +using namespace Qt3DCore; namespace Qt3DExtras { @@ -445,8 +445,8 @@ void QPlaneGeometryPrivate::init() m_texCoordAttribute = new QAttribute(q); m_tangentAttribute = new QAttribute(q); m_indexAttribute = new QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); const int nVerts = m_meshResolution.width() * m_meshResolution.height(); const int stride = (3 + 2 + 3 + 4) * sizeof(float); diff --git a/src/extras/geometries/qplanegeometry.h b/src/extras/geometries/qplanegeometry.h index 91e985700..9cd51abea 100644 --- a/src/extras/geometries/qplanegeometry.h +++ b/src/extras/geometries/qplanegeometry.h @@ -41,33 +41,33 @@ #define QT3DEXTRAS_QPLANEGEOMETRY_H #include -#include +#include #include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { class QPlaneGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QPlaneGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QPlaneGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged) Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged REVISION 9) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *tangentAttribute READ tangentAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *tangentAttribute READ tangentAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QPlaneGeometry(QNode *parent = nullptr); @@ -81,11 +81,11 @@ public: float height() const; bool mirrored() const; - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *texCoordAttribute() const; - Qt3DRender::QAttribute *tangentAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *texCoordAttribute() const; + Qt3DCore::QAttribute *tangentAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; public Q_SLOTS: void setResolution(const QSize &resolution); diff --git a/src/extras/geometries/qplanegeometry_p.h b/src/extras/geometries/qplanegeometry_p.h index b1f63f277..4e87a3781 100644 --- a/src/extras/geometries/qplanegeometry_p.h +++ b/src/extras/geometries/qplanegeometry_p.h @@ -53,20 +53,21 @@ #include -#include +#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { -class QPlaneGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QPlaneGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QPlaneGeometryPrivate(); @@ -76,13 +77,13 @@ public: float m_height; QSize m_meshResolution; bool m_mirrored; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_texCoordAttribute; - Qt3DRender::QAttribute *m_tangentAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_texCoordAttribute; + Qt3DCore::QAttribute *m_tangentAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; Q_DECLARE_PUBLIC(QPlaneGeometry) diff --git a/src/extras/geometries/qplanemesh.h b/src/extras/geometries/qplanemesh.h index eebea1dbf..923af8897 100644 --- a/src/extras/geometries/qplanemesh.h +++ b/src/extras/geometries/qplanemesh.h @@ -87,11 +87,11 @@ private: void setFirstInstance(int firstInstance); void setRestartIndexValue(int index); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(Qt3DRender::QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); }; -} // namespace Qt3DRender +} // namespace Qt3DExtras QT_END_NAMESPACE diff --git a/src/extras/geometries/qspheregeometry.cpp b/src/extras/geometries/qspheregeometry.cpp index ab84b5ff0..c780ba83c 100644 --- a/src/extras/geometries/qspheregeometry.cpp +++ b/src/extras/geometries/qspheregeometry.cpp @@ -40,8 +40,8 @@ #include "qspheregeometry.h" #include "qspheregeometry_p.h" -#include -#include +#include +#include #include @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -using namespace Qt3DRender; +using namespace Qt3DCore; namespace Qt3DExtras { @@ -190,8 +190,8 @@ void QSphereGeometryPrivate::init() m_texCoordAttribute = new QAttribute(q); m_tangentAttribute = new QAttribute(q); m_indexAttribute = new QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); // vec3 pos, vec2 tex, vec3 normal, vec4 tangent const quint32 elementSize = 3 + 2 + 3 + 4; @@ -334,7 +334,7 @@ QByteArray QSphereGeometryPrivate::generateIndexData() const * \brief The QSphereGeometry class allows creation of a sphere in 3D space. * \since 5.7 * \ingroup geometries - * \inherits Qt3DRender::QGeometry + * \inherits Qt3DCore::QGeometry * * The QSphereGeometry class is most commonly used internally by the QSphereMesh * but can also be used in custom Qt3DRender::QGeometryRenderer subclasses. diff --git a/src/extras/geometries/qspheregeometry.h b/src/extras/geometries/qspheregeometry.h index 8bd8c9c94..8f42e4a31 100644 --- a/src/extras/geometries/qspheregeometry.h +++ b/src/extras/geometries/qspheregeometry.h @@ -40,33 +40,33 @@ #ifndef QT3DEXTRAS_QSPHEREGEOMETRY_H #define QT3DEXTRAS_QSPHEREGEOMETRY_H -#include +#include #include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { class QSphereGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QSphereGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QSphereGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(bool generateTangents READ generateTangents WRITE setGenerateTangents NOTIFY generateTangentsChanged) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *tangentAttribute READ tangentAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *tangentAttribute READ tangentAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QSphereGeometry(QNode *parent = nullptr); @@ -80,11 +80,11 @@ public: int slices() const; float radius() const; - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *texCoordAttribute() const; - Qt3DRender::QAttribute *tangentAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *texCoordAttribute() const; + Qt3DCore::QAttribute *tangentAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; public Q_SLOTS: void setRings(int rings); diff --git a/src/extras/geometries/qspheregeometry_p.h b/src/extras/geometries/qspheregeometry_p.h index 2dc83495e..cf31e17c6 100644 --- a/src/extras/geometries/qspheregeometry_p.h +++ b/src/extras/geometries/qspheregeometry_p.h @@ -51,20 +51,21 @@ // We mean it. // -#include +#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { -class QSphereGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QSphereGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QSphereGeometryPrivate(); @@ -74,15 +75,15 @@ public: int m_rings; int m_slices; float m_radius; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_texCoordAttribute; - Qt3DRender::QAttribute *m_tangentAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; - - Q_DECLARE_PUBLIC(QSphereGeometry); + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_texCoordAttribute; + Qt3DCore::QAttribute *m_tangentAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; + + Q_DECLARE_PUBLIC(QSphereGeometry) QByteArray generateVertexData() const; QByteArray generateIndexData() const; diff --git a/src/extras/geometries/qspheremesh.h b/src/extras/geometries/qspheremesh.h index 44e5b81bb..998cd7c0e 100644 --- a/src/extras/geometries/qspheremesh.h +++ b/src/extras/geometries/qspheremesh.h @@ -87,7 +87,7 @@ private: void setFirstInstance(int firstInstance); void setRestartIndexValue(int index); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(Qt3DRender::QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); }; diff --git a/src/extras/geometries/qtorusgeometry.cpp b/src/extras/geometries/qtorusgeometry.cpp index 1e65ab2ef..c9b430043 100644 --- a/src/extras/geometries/qtorusgeometry.cpp +++ b/src/extras/geometries/qtorusgeometry.cpp @@ -40,8 +40,8 @@ #include "qtorusgeometry.h" #include "qtorusgeometry_p.h" -#include -#include +#include +#include #include #include @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -using namespace Qt3DRender; +using namespace Qt3DCore; namespace Qt3DExtras { @@ -176,8 +176,8 @@ void QTorusGeometryPrivate::init() m_texCoordAttribute = new QAttribute(q); m_tangentAttribute = new QAttribute(q); m_indexAttribute = new QAttribute(q); - m_vertexBuffer = new Qt3DRender::QBuffer(q); - m_indexBuffer = new Qt3DRender::QBuffer(q); + m_vertexBuffer = new Qt3DCore::QBuffer(q); + m_indexBuffer = new Qt3DCore::QBuffer(q); // vec3 pos, vec2 tex, vec3 normal, vec4 tangent const quint32 elementSize = 3 + 2 + 3 + 4; const quint32 stride = elementSize * sizeof(float); @@ -311,7 +311,7 @@ QByteArray QTorusGeometryPrivate::generateIndexData() const * \brief The QTorusGeometry class allows creation of a torus in 3D space. * \since 5.7 * \ingroup geometries - * \inherits Qt3DRender::QGeometry + * \inherits Qt3DCore::QGeometry * * The QTorusGeometry class is most commonly used internally by the QTorusMesh * but can also be used in custom Qt3DRender::QGeometryRenderer subclasses. diff --git a/src/extras/geometries/qtorusgeometry.h b/src/extras/geometries/qtorusgeometry.h index cd4a4bb06..3fe159aa7 100644 --- a/src/extras/geometries/qtorusgeometry.h +++ b/src/extras/geometries/qtorusgeometry.h @@ -41,31 +41,31 @@ #define QT3DEXTRAS_QTORUSGEOMETRY_H #include -#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { class QTorusGeometryPrivate; -class Q_3DEXTRASSHARED_EXPORT QTorusGeometry : public Qt3DRender::QGeometry +class Q_3DEXTRASSHARED_EXPORT QTorusGeometry : public Qt3DCore::QGeometry { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(float minorRadius READ minorRadius WRITE setMinorRadius NOTIFY minorRadiusChanged) - Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) - Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT) + Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT) public: explicit QTorusGeometry(QNode *parent = nullptr); @@ -79,10 +79,10 @@ public: float radius() const; float minorRadius() const; - Qt3DRender::QAttribute *positionAttribute() const; - Qt3DRender::QAttribute *normalAttribute() const; - Qt3DRender::QAttribute *texCoordAttribute() const; - Qt3DRender::QAttribute *indexAttribute() const; + Qt3DCore::QAttribute *positionAttribute() const; + Qt3DCore::QAttribute *normalAttribute() const; + Qt3DCore::QAttribute *texCoordAttribute() const; + Qt3DCore::QAttribute *indexAttribute() const; public Q_SLOTS: void setRings(int rings); diff --git a/src/extras/geometries/qtorusgeometry_p.h b/src/extras/geometries/qtorusgeometry_p.h index c05e03835..28572261e 100644 --- a/src/extras/geometries/qtorusgeometry_p.h +++ b/src/extras/geometries/qtorusgeometry_p.h @@ -51,20 +51,21 @@ // We mean it. // -#include +#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { +namespace Qt3DCore { class QAttribute; class QBuffer; -} // Qt3DRender +} // Qt3DCore namespace Qt3DExtras { -class QTorusGeometryPrivate : public Qt3DRender::QGeometryPrivate +class QTorusGeometryPrivate : public Qt3DCore::QGeometryPrivate { public: QTorusGeometryPrivate(); @@ -74,13 +75,13 @@ public: int m_slices; float m_radius; float m_minorRadius; - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QAttribute *m_normalAttribute; - Qt3DRender::QAttribute *m_texCoordAttribute; - Qt3DRender::QAttribute *m_tangentAttribute; - Qt3DRender::QAttribute *m_indexAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QAttribute *m_normalAttribute; + Qt3DCore::QAttribute *m_texCoordAttribute; + Qt3DCore::QAttribute *m_tangentAttribute; + Qt3DCore::QAttribute *m_indexAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; Q_DECLARE_PUBLIC(QTorusGeometry) diff --git a/src/extras/geometries/qtorusmesh.h b/src/extras/geometries/qtorusmesh.h index 97bde10a2..2fd9f0a23 100644 --- a/src/extras/geometries/qtorusmesh.h +++ b/src/extras/geometries/qtorusmesh.h @@ -85,7 +85,7 @@ private: void setFirstInstance(int firstInstance); void setRestartIndexValue(int index); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(Qt3DRender::QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); }; diff --git a/src/extras/text/distancefieldtextrenderer.cpp b/src/extras/text/distancefieldtextrenderer.cpp index 4cf9c0b4a..af4840a36 100644 --- a/src/extras/text/distancefieldtextrenderer.cpp +++ b/src/extras/text/distancefieldtextrenderer.cpp @@ -37,10 +37,10 @@ ** ****************************************************************************/ +#include +#include +#include #include -#include -#include -#include #include #include @@ -77,33 +77,33 @@ void DistanceFieldTextRendererPrivate::init() m_renderer = new Qt3DRender::QGeometryRenderer(q); m_renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Triangles); - m_geometry = new Qt3DRender::QGeometry(m_renderer); + m_geometry = new Qt3DCore::QGeometry(m_renderer); m_renderer->setGeometry(m_geometry); - m_vertexBuffer = new Qt3DRender::QBuffer(m_geometry); - m_indexBuffer = new Qt3DRender::QBuffer(m_geometry); + m_vertexBuffer = new Qt3DCore::QBuffer(m_geometry); + m_indexBuffer = new Qt3DCore::QBuffer(m_geometry); - m_positionAttr = new Qt3DRender::QAttribute(m_geometry); - m_positionAttr->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - m_positionAttr->setVertexBaseType(Qt3DRender::QAttribute::Float); - m_positionAttr->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + m_positionAttr = new Qt3DCore::QAttribute(m_geometry); + m_positionAttr->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + m_positionAttr->setVertexBaseType(Qt3DCore::QAttribute::Float); + m_positionAttr->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); m_positionAttr->setVertexSize(3); m_positionAttr->setByteStride(5 * sizeof(float)); m_positionAttr->setByteOffset(0); m_positionAttr->setBuffer(m_vertexBuffer); - m_texCoordAttr = new Qt3DRender::QAttribute(m_geometry); - m_texCoordAttr->setName(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); - m_texCoordAttr->setVertexBaseType(Qt3DRender::QAttribute::Float); - m_texCoordAttr->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + m_texCoordAttr = new Qt3DCore::QAttribute(m_geometry); + m_texCoordAttr->setName(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); + m_texCoordAttr->setVertexBaseType(Qt3DCore::QAttribute::Float); + m_texCoordAttr->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); m_texCoordAttr->setVertexSize(2); m_texCoordAttr->setByteStride(5 * sizeof(float)); m_texCoordAttr->setByteOffset(3 * sizeof(float)); m_texCoordAttr->setBuffer(m_vertexBuffer); - m_indexAttr = new Qt3DRender::QAttribute(m_geometry); - m_indexAttr->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); - m_indexAttr->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + m_indexAttr = new Qt3DCore::QAttribute(m_geometry); + m_indexAttr->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); + m_indexAttr->setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); m_indexAttr->setBuffer(m_indexBuffer); m_geometry->addAttribute(m_positionAttr); diff --git a/src/extras/text/distancefieldtextrenderer_p_p.h b/src/extras/text/distancefieldtextrenderer_p_p.h index af4bc4723..76471c5ba 100644 --- a/src/extras/text/distancefieldtextrenderer_p_p.h +++ b/src/extras/text/distancefieldtextrenderer_p_p.h @@ -56,14 +56,17 @@ QT_BEGIN_NAMESPACE -namespace Qt3DRender { -class QGeometryRenderer; +namespace Qt3DCore { class QGeometry; class QMaterial; class QAttribute; class QBuffer; } +namespace Qt3DRender { +class QGeometryRenderer; +} + namespace Qt3DExtras { class QText2DMaterial; @@ -79,12 +82,12 @@ public: void init(); Qt3DRender::QGeometryRenderer *m_renderer; - Qt3DRender::QGeometry *m_geometry; - Qt3DRender::QAttribute *m_positionAttr; - Qt3DRender::QAttribute *m_texCoordAttr; - Qt3DRender::QAttribute *m_indexAttr; - Qt3DRender::QBuffer *m_vertexBuffer; - Qt3DRender::QBuffer *m_indexBuffer; + Qt3DCore::QGeometry *m_geometry; + Qt3DCore::QAttribute *m_positionAttr; + Qt3DCore::QAttribute *m_texCoordAttr; + Qt3DCore::QAttribute *m_indexAttr; + Qt3DCore::QBuffer *m_vertexBuffer; + Qt3DCore::QBuffer *m_indexBuffer; QText2DMaterial *m_material; }; diff --git a/src/extras/text/qtext2dentity.cpp b/src/extras/text/qtext2dentity.cpp index 897672782..a159ffab5 100644 --- a/src/extras/text/qtext2dentity.cpp +++ b/src/extras/text/qtext2dentity.cpp @@ -48,10 +48,10 @@ #include #include +#include +#include +#include #include -#include -#include -#include #include #include diff --git a/src/extras/text/qtextureatlas.cpp b/src/extras/text/qtextureatlas.cpp index 4ab992224..d5d97a3a7 100644 --- a/src/extras/text/qtextureatlas.cpp +++ b/src/extras/text/qtextureatlas.cpp @@ -175,7 +175,7 @@ Qt3DRender::QTextureDataPtr QTextureAtlasGenerator::operator()() bool QTextureAtlasGenerator::operator==(const QTextureGenerator &other) const { - const QTextureAtlasGenerator *otherFunctor = Qt3DRender::functor_cast(&other); + const QTextureAtlasGenerator *otherFunctor = Qt3DCore::functor_cast(&other); return (otherFunctor != nullptr && otherFunctor->m_data == m_data && otherFunctor->m_atlasId == m_atlasId diff --git a/src/plugins/geometryloaders/default/basegeometryloader.cpp b/src/plugins/geometryloaders/default/basegeometryloader.cpp index 46e912a4e..a7c226c68 100644 --- a/src/plugins/geometryloaders/default/basegeometryloader.cpp +++ b/src/plugins/geometryloaders/default/basegeometryloader.cpp @@ -39,15 +39,17 @@ #include "basegeometryloader_p.h" -#include -#include -#include +#include +#include +#include #include #include QT_BEGIN_NAMESPACE +using namespace Qt3DCore; + namespace Qt3DRender { Q_LOGGING_CATEGORY(BaseGeometryLoaderLog, "Qt3D.BaseGeometryLoader", QtWarningMsg) @@ -60,7 +62,7 @@ BaseGeometryLoader::BaseGeometryLoader() { } -QGeometry *BaseGeometryLoader::geometry() const +Qt3DCore::QGeometry *BaseGeometryLoader::geometry() const { return m_geometry; } diff --git a/src/plugins/geometryloaders/default/basegeometryloader_p.h b/src/plugins/geometryloaders/default/basegeometryloader_p.h index 0fe1e2763..2f9e25fab 100644 --- a/src/plugins/geometryloaders/default/basegeometryloader_p.h +++ b/src/plugins/geometryloaders/default/basegeometryloader_p.h @@ -67,9 +67,11 @@ QT_BEGIN_NAMESPACE class QIODevice; class QString; -namespace Qt3DRender { - +namespace Qt3DCore { class QGeometry; +} + +namespace Qt3DRender { class BaseGeometryLoader : public QGeometryLoaderInterface { @@ -96,7 +98,7 @@ public: QVector tangents() const { return m_tangents; } QVector indices() const { return m_indices; } - QGeometry *geometry() const override; + Qt3DCore::QGeometry *geometry() const override; bool load(QIODevice *ioDev, const QString &subMesh = QString()) override; @@ -124,7 +126,7 @@ protected: QVector m_tangents; QVector m_indices; - QGeometry *m_geometry; + Qt3DCore::QGeometry *m_geometry; }; struct FaceIndices diff --git a/src/plugins/geometryloaders/fbx/fbxgeometryloader.cpp b/src/plugins/geometryloaders/fbx/fbxgeometryloader.cpp index 355096448..e8b92dc82 100644 --- a/src/plugins/geometryloaders/fbx/fbxgeometryloader.cpp +++ b/src/plugins/geometryloaders/fbx/fbxgeometryloader.cpp @@ -41,9 +41,9 @@ #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp b/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp index 2c8bb14c3..9f13ca2c6 100644 --- a/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp +++ b/src/plugins/geometryloaders/gltf/gltfgeometryloader.cpp @@ -46,8 +46,8 @@ #include -#include #include +#include #include QT_BEGIN_NAMESPACE @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE static_cast(static_cast(string.utf16())) #endif +using namespace Qt3DCore; + namespace Qt3DRender { Q_LOGGING_CATEGORY(GLTFGeometryLoaderLog, "Qt3D.GLTFGeometryLoader", QtWarningMsg) @@ -326,7 +328,7 @@ void GLTFGeometryLoader::processJSONBufferView(const QString &id, const QJsonObj qUtf16PrintableImpl(bufferData.path), qUtf16PrintableImpl(id)); } - Qt3DRender::QBuffer *b = new Qt3DRender::QBuffer(); + Qt3DCore::QBuffer *b = new Qt3DCore::QBuffer(); b->setData(bytes); m_gltf1.m_buffers[id] = b; } @@ -363,7 +365,7 @@ void GLTFGeometryLoader::processJSONBufferViewV2(const QJsonObject &json) qUtf16PrintableImpl(bufferData.path)); } - auto b = new Qt3DRender::QBuffer; + auto b = new Qt3DCore::QBuffer; b->setData(bytes); m_gltf2.m_buffers.push_back(b); } @@ -409,7 +411,7 @@ void GLTFGeometryLoader::processJSONMesh(const QString &id, const QJsonObject &j attributeName = attrName; //Get buffer handle for accessor - Qt3DRender::QBuffer *buffer = m_gltf1.m_buffers.value(accessorIt->bufferViewName, nullptr); + Qt3DCore::QBuffer *buffer = m_gltf1.m_buffers.value(accessorIt->bufferViewName, nullptr); if (Q_UNLIKELY(!buffer)) { qCWarning(GLTFGeometryLoaderLog, "unknown buffer-view: %ls processing accessor: %ls", qUtf16PrintableImpl(accessorIt->bufferViewName), qUtf16PrintableImpl(id)); @@ -436,7 +438,7 @@ void GLTFGeometryLoader::processJSONMesh(const QString &id, const QJsonObject &j qUtf16PrintableImpl(k), qUtf16PrintableImpl(id)); } else { //Get buffer handle for accessor - Qt3DRender::QBuffer *buffer = m_gltf1.m_buffers.value(accessorIt->bufferViewName, nullptr); + Qt3DCore::QBuffer *buffer = m_gltf1.m_buffers.value(accessorIt->bufferViewName, nullptr); if (Q_UNLIKELY(!buffer)) { qCWarning(GLTFGeometryLoaderLog, "unknown buffer-view: %ls processing accessor: %ls", qUtf16PrintableImpl(accessorIt->bufferViewName), qUtf16PrintableImpl(id)); @@ -489,7 +491,7 @@ void GLTFGeometryLoader::processJSONMeshV2(const QJsonObject &json) accessor.bufferViewIndex, qUtf16PrintableImpl(json.value(KEY_NAME).toString())); continue; } - Qt3DRender::QBuffer *buffer = m_gltf2.m_buffers[accessor.bufferViewIndex]; + Qt3DCore::QBuffer *buffer = m_gltf2.m_buffers[accessor.bufferViewIndex]; QAttribute *attribute = new QAttribute(buffer, attributeName, @@ -517,7 +519,7 @@ void GLTFGeometryLoader::processJSONMeshV2(const QJsonObject &json) accessor.bufferViewIndex, qUtf16PrintableImpl(json.value(KEY_NAME).toString())); continue; } - Qt3DRender::QBuffer *buffer = m_gltf2.m_buffers[accessor.bufferViewIndex]; + Qt3DCore::QBuffer *buffer = m_gltf2.m_buffers[accessor.bufferViewIndex]; QAttribute *attribute = new QAttribute(buffer, accessor.type, diff --git a/src/plugins/geometryloaders/gltf/gltfgeometryloader.h b/src/plugins/geometryloaders/gltf/gltfgeometryloader.h index 404668dd0..36ac0f174 100644 --- a/src/plugins/geometryloaders/gltf/gltfgeometryloader.h +++ b/src/plugins/geometryloaders/gltf/gltfgeometryloader.h @@ -54,13 +54,17 @@ #include #include -#include -#include +#include +#include #include QT_BEGIN_NAMESPACE +namespace Qt3DCore { +class QGeometry; +} + namespace Qt3DRender { #define GLTFGEOMETRYLOADER_EXT QLatin1String("gltf") @@ -77,7 +81,6 @@ class QRenderState; class QTechnique; class QParameter; class QGeometryRenderer; -class QGeometry; class GLTFGeometryLoader : public QGeometryLoaderInterface { @@ -111,7 +114,7 @@ class GLTFGeometryLoader : public QGeometryLoaderInterface QString bufferViewName; int bufferViewIndex; - QAttribute::VertexBaseType type; + Qt3DCore::QAttribute::VertexBaseType type; uint dataSize; int count; int offset; @@ -122,13 +125,13 @@ class GLTFGeometryLoader : public QGeometryLoaderInterface { QHash m_accessorDict; QHash m_bufferDatas; - QHash m_buffers; + QHash m_buffers; }; struct Gltf2 { QVector m_bufferDatas; - QVector m_buffers; + QVector m_buffers; QVector m_accessors; }; @@ -137,7 +140,7 @@ public: GLTFGeometryLoader(); ~GLTFGeometryLoader(); - QGeometry *geometry() const final; + Qt3DCore::QGeometry *geometry() const final; bool load(QIODevice *ioDev, const QString &subMesh = QString()) final; @@ -170,7 +173,7 @@ protected: QByteArray resolveLocalData(const QString &path) const; - static QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); + static Qt3DCore::QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); static uint accessorDataSizeFromJson(const QString &type); private: @@ -181,7 +184,7 @@ private: Gltf1 m_gltf1; Gltf2 m_gltf2; - QGeometry *m_geometry; + Qt3DCore::QGeometry *m_geometry; }; } // namespace Qt3DRender diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicscontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/graphicscontext.cpp index 508b38755..30a8184b5 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicscontext.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicscontext.cpp @@ -52,9 +52,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -971,8 +969,10 @@ GLuint GraphicsContext::byteSizeFromType(GLint type) return 0; } -GLint GraphicsContext::glDataTypeFromAttributeDataType(QAttribute::VertexBaseType dataType) +GLint GraphicsContext::glDataTypeFromAttributeDataType(Qt3DCore::QAttribute::VertexBaseType dataType) { + using namespace Qt3DCore; + switch (dataType) { case QAttribute::Byte: return GL_BYTE; diff --git a/src/plugins/renderers/opengl/graphicshelpers/graphicscontext_p.h b/src/plugins/renderers/opengl/graphicshelpers/graphicscontext_p.h index 8da1a420c..ba474a89b 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/graphicscontext_p.h +++ b/src/plugins/renderers/opengl/graphicshelpers/graphicscontext_p.h @@ -60,9 +60,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -184,7 +184,7 @@ public: static GLint elementType(GLint type); static GLint tupleSizeFromType(GLint type); static GLuint byteSizeFromType(GLint type); - static GLint glDataTypeFromAttributeDataType(QAttribute::VertexBaseType dataType); + static GLint glDataTypeFromAttributeDataType(Qt3DCore::QAttribute::VertexBaseType dataType); bool supportsDrawBuffersBlend() const; bool supportsVAO() const { return m_supportsVAO; } diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp index b22477435..519f2ae98 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp @@ -39,6 +39,7 @@ #include "submissioncontext_p.h" +#include #include #include #include @@ -54,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -97,6 +97,8 @@ QT_BEGIN_NAMESPACE #define GL_DRAW_FRAMEBUFFER 0x8CA9 #endif +using namespace Qt3DCore; + namespace Qt3DRender { namespace Render { namespace OpenGL { @@ -1461,7 +1463,7 @@ void SubmissionContext::uploadDataToGLBuffer(Buffer *buffer, GLBuffer *b, bool r // * partial buffer updates where received // TO DO: Handle usage pattern - QVector updates = std::move(buffer->pendingBufferUpdates()); + QVector updates = std::move(buffer->pendingBufferUpdates()); for (auto it = updates.begin(); it != updates.end(); ++it) { auto update = it; // We have a partial update diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h index d43cae4f8..59b2b78f3 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h +++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h @@ -59,7 +59,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/renderers/opengl/renderer/renderer.cpp b/src/plugins/renderers/opengl/renderer/renderer.cpp index 2dafa15c5..deb77ee4b 100644 --- a/src/plugins/renderers/opengl/renderer/renderer.cpp +++ b/src/plugins/renderers/opengl/renderer/renderer.cpp @@ -1116,7 +1116,7 @@ void Renderer::lookForDownloadableBuffers() const QVector activeBufferHandles = m_nodesManager->bufferManager()->activeHandles(); for (const HBuffer &handle : activeBufferHandles) { Buffer *buffer = m_nodesManager->bufferManager()->data(handle); - if (buffer->access() & QBuffer::Read) + if (buffer->access() & Qt3DCore::QBuffer::Read) m_downloadableBuffers.push_back(buffer->peerId()); } } diff --git a/src/plugins/renderers/opengl/renderer/renderview.cpp b/src/plugins/renderers/opengl/renderer/renderview.cpp index 47f4beffd..326a8a91b 100644 --- a/src/plugins/renderers/opengl/renderer/renderview.cpp +++ b/src/plugins/renderers/opengl/renderer/renderview.cpp @@ -381,8 +381,8 @@ struct SubRangeSorter { static void sortSubRange(CommandIt begin, const CommandIt end) { - Q_UNUSED(begin); - Q_UNUSED(end); + Q_UNUSED(begin) + Q_UNUSED(end) Q_UNREACHABLE(); } }; @@ -705,13 +705,13 @@ EntityRenderCommandData RenderView::buildDrawRenderCommands(const QVectorattributeManager()->lookupResource(attributeId); switch (attribute->attributeType()) { - case QAttribute::IndexAttribute: + case Qt3DCore::QAttribute::IndexAttribute: indexAttribute = attribute; break; - case QAttribute::DrawIndirectAttribute: + case Qt3DCore::QAttribute::DrawIndirectAttribute: indirectAttribute = attribute; break; - case QAttribute::VertexAttribute: + case Qt3DCore::QAttribute::VertexAttribute: estimatedCount = std::max(int(attribute->count()), estimatedCount); break; default: diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.cpp b/src/plugins/sceneparsers/assimp/assimpimporter.cpp index ef28c577f..7655bf931 100644 --- a/src/plugins/sceneparsers/assimp/assimpimporter.cpp +++ b/src/plugins/sceneparsers/assimp/assimpimporter.cpp @@ -41,20 +41,20 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include #include #include -#include #include #include #include #include #include #include +#include +#include +#include #include #include #include @@ -67,8 +67,8 @@ #include #include +#include #include -#include QT_BEGIN_NAMESPACE @@ -394,7 +394,7 @@ bool AssimpImporter::areAssimpExtensions(const QStringList &extensions) */ void AssimpImporter::setSource(const QUrl &source) { - const QString path = QUrlHelper::urlToLocalFileOrQrc(source); + const QString path = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(source); QFileInfo file(path); m_sceneDir = file.absoluteDir(); if (!file.exists()) { @@ -702,12 +702,12 @@ QGeometryRenderer *AssimpImporter::loadMesh(uint meshIndex) QGeometryRenderer *geometryRenderer = QAbstractNodeFactory::createNode("QGeometryRenderer"); QGeometry *meshGeometry = QAbstractNodeFactory::createNode("QGeometry"); meshGeometry->setParent(geometryRenderer); - Qt3DRender::QBuffer *vertexBuffer = QAbstractNodeFactory::createNode("QBuffer"); + Qt3DCore::QBuffer *vertexBuffer = QAbstractNodeFactory::createNode("QBuffer"); vertexBuffer->setParent(meshGeometry); - vertexBuffer->setType(Qt3DRender::QBuffer::VertexBuffer); - Qt3DRender::QBuffer *indexBuffer = QAbstractNodeFactory::createNode("QBuffer"); + vertexBuffer->setType(Qt3DCore::QBuffer::VertexBuffer); + Qt3DCore::QBuffer *indexBuffer = QAbstractNodeFactory::createNode("QBuffer"); indexBuffer->setParent(meshGeometry); - indexBuffer->setType(Qt3DRender::QBuffer::IndexBuffer); + indexBuffer->setType(Qt3DCore::QBuffer::IndexBuffer); geometryRenderer->setGeometry(meshGeometry); @@ -922,8 +922,8 @@ QGeometryRenderer *AssimpImporter::loadMesh(uint meshIndex) } } - Qt3DRender::QBuffer *targetBuffer - = QAbstractNodeFactory::createNode("QBuffer"); + Qt3DCore::QBuffer *targetBuffer + = QAbstractNodeFactory::createNode("QBuffer"); targetBuffer->setData(targetBufferArray); targetBuffer->setParent(meshGeometry); diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp index 860dec3e7..b141a44a5 100644 --- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp +++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -74,7 +75,6 @@ #include #include #include -#include #include #include #include @@ -1522,7 +1522,7 @@ void GLTFImporter::processJSONBufferView(const QString &id, const QJsonObject& j qUtf16PrintableImpl(bufferData.path), qUtf16PrintableImpl(id)); } - Qt3DRender::QBuffer *b = new Qt3DRender::QBuffer(); + Qt3DCore::QBuffer *b = new Qt3DCore::QBuffer(); b->setData(bytes); m_buffers[id] = b; } @@ -1768,7 +1768,7 @@ void GLTFImporter::processJSONMesh(const QString &id, const QJsonObject &json) attributeName = attrName; //Get buffer handle for accessor - Qt3DRender::QBuffer *buffer = m_buffers.value(accessorIt->bufferViewName, nullptr); + Qt3DCore::QBuffer *buffer = m_buffers.value(accessorIt->bufferViewName, nullptr); if (Q_UNLIKELY(!buffer)) { qCWarning(GLTFImporterLog, "unknown buffer-view: %ls processing accessor: %ls", qUtf16PrintableImpl(accessorIt->bufferViewName), @@ -1796,7 +1796,7 @@ void GLTFImporter::processJSONMesh(const QString &id, const QJsonObject &json) qUtf16PrintableImpl(accIndex), qUtf16PrintableImpl(id)); } else { //Get buffer handle for accessor - Qt3DRender::QBuffer *buffer = m_buffers.value(accessorIt->bufferViewName, nullptr); + Qt3DCore::QBuffer *buffer = m_buffers.value(accessorIt->bufferViewName, nullptr); if (Q_UNLIKELY(!buffer)) { qCWarning(GLTFImporterLog, "unknown buffer-view: %ls processing accessor: %ls", qUtf16PrintableImpl(accessorIt->bufferViewName), diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.h b/src/plugins/sceneparsers/gltf/gltfimporter.h index 271ce5979..79f35ebad 100644 --- a/src/plugins/sceneparsers/gltf/gltfimporter.h +++ b/src/plugins/sceneparsers/gltf/gltfimporter.h @@ -52,8 +52,8 @@ // We mean it. // -#include -#include +#include +#include #include #include #include @@ -135,7 +135,7 @@ private: explicit AccessorData(const QJsonObject& json, int major, int minor); QString bufferViewName; - QAttribute::VertexBaseType type; + Qt3DCore::QAttribute::VertexBaseType type; uint dataSize; int count; int offset; @@ -178,7 +178,7 @@ private: QByteArray resolveLocalData(const QString &path) const; QVariant parameterValueFromJSON(int type, const QJsonValue &value) const; - static QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); + static Qt3DCore::QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); static uint accessorDataSizeFromJson(const QString &type); static QRenderState *buildStateEnable(int state); @@ -212,7 +212,7 @@ private: QHash m_materialCache; QHash m_bufferDatas; - QHash m_buffers; + QHash m_buffers; QHash m_shaderPaths; QHash m_programs; diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp index 9fced8e89..8b4fac1ce 100644 --- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp +++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp @@ -58,14 +58,15 @@ #include #include +#include +#include +#include #include #include #include #include #include #include -#include -#include #include #include #include @@ -74,7 +75,6 @@ #include #include #include -#include #include #include #include diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp index 75fa7b2da..a15629b68 100644 --- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp +++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp @@ -44,6 +44,9 @@ #include #include #include +#include +#include +#include #include #include @@ -53,6 +56,8 @@ #include #include #include +#include +#include #include @@ -73,6 +78,13 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 10, "Armature"); qmlRegisterUncreatableType(uri, 2, 10, "AbstractSkeleton", QStringLiteral("AbstractSkeleton is an abstract base class")); qmlRegisterType(uri, 2, 10, "SkeletonLoader"); + qmlRegisterType(uri, 2, 0, "Attribute"); + qmlRegisterType(uri, 2, 10, "Attribute"); + qmlRegisterType(uri, 2, 11, "Attribute"); + qmlRegisterUncreatableType(uri, 2, 0, "BufferBase", QStringLiteral("Use Quick3DBuffer in QML")); + qmlRegisterUncreatableType(uri, 2, 9, "BufferBase", QStringLiteral("Use Quick3DBuffer in QML")); + qmlRegisterType(uri, 2, 0, "Buffer"); + Qt3DCore::Quick::registerExtendedType("QGeometry", "Qt3D.Core/Geometry", uri, 2, 0, "Geometry"); qmlRegisterType(uri, 2, 0, "QuaternionAnimation"); qRegisterAnimationInterpolator(Qt3DCore::Quick::q_quaternionInterpolator); diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp index e42be550d..9992ace97 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp @@ -42,10 +42,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -65,7 +63,6 @@ #include #include #include -#include #include #include #include @@ -125,9 +122,7 @@ #include #include -#include #include -#include #include #include #include @@ -223,13 +218,6 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 14, "ShaderImage"); // Geometry - qmlRegisterType(uri, 2, 0, "Attribute"); - qmlRegisterType(uri, 2, 10, "Attribute"); - qmlRegisterType(uri, 2, 11, "Attribute"); - qmlRegisterUncreatableType(uri, 2, 0, "BufferBase", QStringLiteral("Use Quick3DBuffer in QML")); - qmlRegisterUncreatableType(uri, 2, 9, "BufferBase", QStringLiteral("Use Quick3DBuffer in QML")); - qmlRegisterType(uri, 2, 0, "Buffer"); - Qt3DRender::Quick::registerExtendedType("QGeometry", "Qt3D.Render/Geometry", uri, 2, 0, "Geometry"); qmlRegisterType(uri, 2, 0, "GeometryRenderer"); qmlRegisterType(uri, 2, 9, "LevelOfDetail"); qmlRegisterType(uri, 2, 9, "LevelOfDetailSwitch"); diff --git a/src/quick3d/quick3d/items/items.pri b/src/quick3d/quick3d/items/items.pri index 36e7ccedc..febe5c395 100644 --- a/src/quick3d/quick3d/items/items.pri +++ b/src/quick3d/quick3d/items/items.pri @@ -5,7 +5,9 @@ HEADERS += \ $$PWD/quick3dentityloader_p.h \ $$PWD/quick3dnode_p.h \ $$PWD/quick3dnodev9_p.h \ - $$PWD/quick3djoint_p.h + $$PWD/quick3djoint_p.h \ + $$PWD/quick3dbuffer_p.h \ + $$PWD/quick3dgeometry_p.h SOURCES += \ $$PWD/quick3dnode.cpp \ @@ -13,6 +15,8 @@ SOURCES += \ $$PWD/quick3dentityloader.cpp \ $$PWD/quick3dnodeinstantiator.cpp \ $$PWD/quick3dnodev9.cpp \ - $$PWD/quick3djoint.cpp + $$PWD/quick3djoint.cpp \ + $$PWD/quick3dbuffer.cpp \ + $$PWD/quick3dgeometry.cpp INCLUDEPATH += $$PWD diff --git a/src/quick3d/quick3d/items/quick3dbuffer.cpp b/src/quick3d/quick3d/items/quick3dbuffer.cpp new file mode 100644 index 000000000..7beb1cc90 --- /dev/null +++ b/src/quick3d/quick3d/items/quick3dbuffer.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +namespace Quick { + +namespace { +const int jsValueTypeId = qMetaTypeId(); +} + +Quick3DBuffer::Quick3DBuffer(Qt3DCore::QNode *parent) + : Qt3DCore::QBuffer(parent) + , m_engine(nullptr) + , m_v4engine(nullptr) +{ + QObject::connect(this, &Qt3DCore::QBuffer::dataChanged, this, &Quick3DBuffer::bufferDataChanged); +} + +QByteArray Quick3DBuffer::convertToRawData(const QJSValue &jsValue) +{ + initEngines(); + Q_ASSERT(m_v4engine); + QV4::Scope scope(m_v4engine); + QV4::Scoped typedArray(scope, + QJSValuePrivate::convertedToValue(m_v4engine, jsValue)); + if (!typedArray) + return QByteArray(); + + char *dataPtr = reinterpret_cast(typedArray->arrayData()->data()); + dataPtr += typedArray->d()->byteOffset; + uint byteLength = typedArray->byteLength(); + return QByteArray(dataPtr, byteLength); +} + +QVariant Quick3DBuffer::bufferData() const +{ + return QVariant::fromValue(data()); +} + +void Quick3DBuffer::setBufferData(const QVariant &bufferData) +{ + if (bufferData.userType() == QMetaType::QByteArray) { + QBuffer::setData(bufferData.toByteArray()); + } else if (bufferData.userType() == jsValueTypeId) { + QJSValue jsValue = bufferData.value(); + QBuffer::setData(convertToRawData(jsValue)); + } +} + +void Quick3DBuffer::updateData(int offset, const QVariant &bufferData) +{ + if (bufferData.userType() == QMetaType::QByteArray) { + QBuffer::updateData(offset, bufferData.toByteArray()); + } else if (bufferData.userType() == jsValueTypeId) { + QJSValue jsValue = bufferData.value(); + QBuffer::updateData(offset, convertToRawData(jsValue)); + } +} + +/*! + \qmlmethod string Quick3DBuffer::readBinaryFile(url &fileUrl) + + Reads the binary at \a fileUrl and return it as a QByteArray wrapped in a + QVariant + + \note this is provided as convenience for QML where reading files and creating + QByteArray is not possible + */ +QVariant Quick3DBuffer::readBinaryFile(const QUrl &fileUrl) +{ + QFile f(Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(fileUrl)); + QByteArray data; + + if (f.open(QIODevice::ReadOnly)) + data = f.readAll(); + return QVariant(data); +} + +void Quick3DBuffer::initEngines() +{ + if (m_engine == nullptr) { + m_engine = qmlEngine(parent()); + m_v4engine = QQmlEnginePrivate::getV4Engine(m_engine); + } +} + +} // Quick +} // Qt3DCore + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3d/items/quick3dbuffer_p.h b/src/quick3d/quick3d/items/quick3dbuffer_p.h new file mode 100644 index 000000000..b75164e4c --- /dev/null +++ b/src/quick3d/quick3d/items/quick3dbuffer_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_P_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QQmlEngine; +class QJSValue; + +namespace QV4 { +struct ExecutionEngine; +} + +namespace Qt3DCore { + +namespace Quick { + +class Q_3DQUICKSHARED_PRIVATE_EXPORT Quick3DBuffer : public Qt3DCore::QBuffer +{ + Q_OBJECT + Q_PROPERTY(QVariant data READ bufferData WRITE setBufferData NOTIFY bufferDataChanged) +public: + explicit Quick3DBuffer(Qt3DCore::QNode *parent = nullptr); + + QVariant bufferData() const; + void setBufferData(const QVariant &bufferData); + + Q_INVOKABLE QVariant readBinaryFile(const QUrl &fileUrl); + +public Q_SLOTS: + void updateData(int offset, const QVariant &bytes); + +Q_SIGNALS: + void bufferDataChanged(); + +private: + QQmlEngine *m_engine; + QV4::ExecutionEngine *m_v4engine; + void initEngines(); + QByteArray convertToRawData(const QJSValue &jsValue); +}; + +} // Quick + +} // Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_P_H diff --git a/src/quick3d/quick3d/items/quick3dgeometry.cpp b/src/quick3d/quick3d/items/quick3dgeometry.cpp new file mode 100644 index 000000000..8e9e56fab --- /dev/null +++ b/src/quick3d/quick3d/items/quick3dgeometry.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +namespace Quick { + +Quick3DGeometry::Quick3DGeometry(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty Quick3DGeometry::attributeList() +{ + return QQmlListProperty(this, nullptr, + &Quick3DGeometry::appendAttribute, + &Quick3DGeometry::attributesCount, + &Quick3DGeometry::attributeAt, + &Quick3DGeometry::clearAttributes); +} + +void Quick3DGeometry::appendAttribute(QQmlListProperty *list, Qt3DCore::QAttribute *attribute) +{ + Quick3DGeometry *geometry = static_cast(list->object); + geometry->m_managedAttributes.append(attribute); + geometry->parentGeometry()->addAttribute(attribute); +} + +Qt3DCore::QAttribute *Quick3DGeometry::attributeAt(QQmlListProperty *list, int index) +{ + Quick3DGeometry *geometry = static_cast(list->object); + return geometry->parentGeometry()->attributes().at(index); +} + +int Quick3DGeometry::attributesCount(QQmlListProperty *list) +{ + Quick3DGeometry *geometry = static_cast(list->object); + return geometry->parentGeometry()->attributes().count(); +} + +void Quick3DGeometry::clearAttributes(QQmlListProperty *list) +{ + Quick3DGeometry *geometry = static_cast(list->object); + for (Qt3DCore::QAttribute *attribute : qAsConst(geometry->m_managedAttributes)) + geometry->parentGeometry()->removeAttribute(attribute); + geometry->m_managedAttributes.clear(); +} + +} // namespace Quick +} // namespace Qt3DCore + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3d/items/quick3dgeometry_p.h b/src/quick3d/quick3d/items/quick3dgeometry_p.h new file mode 100644 index 000000000..39bafbea7 --- /dev/null +++ b/src/quick3d/quick3d/items/quick3dgeometry_p.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3D_QUICK3DGEOMETRY_P_H +#define QT3D_QUICK3DGEOMETRY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +namespace Quick { + +class Q_3DQUICKSHARED_PRIVATE_EXPORT Quick3DGeometry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty attributes READ attributeList) + Q_CLASSINFO("DefaultProperty", "attributes") + +public: + explicit Quick3DGeometry(QObject *parent = nullptr); + inline QGeometry *parentGeometry() const { return qobject_cast(parent()); } + + QQmlListProperty attributeList(); + +private: + static void appendAttribute(QQmlListProperty *list, Qt3DCore::QAttribute *provider); + static Qt3DCore::QAttribute *attributeAt(QQmlListProperty *list, int index); + static int attributesCount(QQmlListProperty *list); + static void clearAttributes(QQmlListProperty *list); + + QVector m_managedAttributes; +}; + +} // namespace Quick +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3D_QUICK3DGEOMETRY_P_H diff --git a/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp b/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp index 81144e186..030d5abe5 100644 --- a/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp +++ b/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp @@ -46,23 +46,23 @@ QQuick3DMorphTarget::QQuick3DMorphTarget(QObject *parent) { } -QQmlListProperty QQuick3DMorphTarget::attributes() +QQmlListProperty QQuick3DMorphTarget::attributes() { - return QQmlListProperty(this, 0, + return QQmlListProperty(this, 0, &QQuick3DMorphTarget::appendAttribute, &QQuick3DMorphTarget::attributeCount, &QQuick3DMorphTarget::attributeAt, &QQuick3DMorphTarget::clearAttributes); } -void QQuick3DMorphTarget::appendAttribute(QQmlListProperty *list, Qt3DRender::QAttribute *bar) +void QQuick3DMorphTarget::appendAttribute(QQmlListProperty *list, Qt3DCore::QAttribute *bar) { QQuick3DMorphTarget *target = qobject_cast(list->object); if (target) target->parentMorphTarget()->addAttribute(bar); } -int QQuick3DMorphTarget::attributeCount(QQmlListProperty *list) +int QQuick3DMorphTarget::attributeCount(QQmlListProperty *list) { QQuick3DMorphTarget *target = qobject_cast(list->object); if (target) @@ -70,19 +70,19 @@ int QQuick3DMorphTarget::attributeCount(QQmlListProperty return 0; } -Qt3DRender::QAttribute *QQuick3DMorphTarget::attributeAt(QQmlListProperty *list, int index) +Qt3DCore::QAttribute *QQuick3DMorphTarget::attributeAt(QQmlListProperty *list, int index) { QQuick3DMorphTarget *target = qobject_cast(list->object); if (target) - return qobject_cast(target->parentMorphTarget()->attributeList().at(index)); + return qobject_cast(target->parentMorphTarget()->attributeList().at(index)); return nullptr; } -void QQuick3DMorphTarget::clearAttributes(QQmlListProperty *list) +void QQuick3DMorphTarget::clearAttributes(QQmlListProperty *list) { QQuick3DMorphTarget *target = qobject_cast(list->object); if (target) { - QVector emptyList; + QVector emptyList; target->parentMorphTarget()->setAttributes(emptyList); } } diff --git a/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h b/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h index 5ca783e6b..d68a795e9 100644 --- a/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h +++ b/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h @@ -60,21 +60,21 @@ namespace Quick { class Q_3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DMorphTarget : public QObject { Q_OBJECT - Q_PROPERTY(QQmlListProperty attributes READ attributes) + Q_PROPERTY(QQmlListProperty attributes READ attributes) public: QQuick3DMorphTarget(QObject *parent = nullptr); inline QMorphTarget *parentMorphTarget() const { return qobject_cast(parent()); } - QQmlListProperty attributes(); + QQmlListProperty attributes(); private: - static void appendAttribute(QQmlListProperty *list, Qt3DRender::QAttribute *bar); - static Qt3DRender::QAttribute *attributeAt(QQmlListProperty *list, int index); - static int attributeCount(QQmlListProperty *list); - static void clearAttributes(QQmlListProperty *list); + static void appendAttribute(QQmlListProperty *list, Qt3DCore::QAttribute *bar); + static Qt3DCore::QAttribute *attributeAt(QQmlListProperty *list, int index); + static int attributeCount(QQmlListProperty *list); + static void clearAttributes(QQmlListProperty *list); }; } // namespace Quick diff --git a/src/quick3d/quick3drender/items/items.pri b/src/quick3d/quick3drender/items/items.pri index e264624b3..4bfb1ae4a 100644 --- a/src/quick3d/quick3drender/items/items.pri +++ b/src/quick3d/quick3drender/items/items.pri @@ -1,8 +1,6 @@ HEADERS += \ $$PWD/quick3dtechniquefilter_p.h \ - $$PWD/quick3dbuffer_p.h \ $$PWD/quick3deffect_p.h \ - $$PWD/quick3dgeometry_p.h \ $$PWD/quick3dlayerfilter_p.h \ $$PWD/quick3dmaterial_p.h \ $$PWD/quick3drenderpass_p.h \ @@ -40,8 +38,6 @@ SOURCES += \ $$PWD/quick3dshaderdataarray.cpp \ $$PWD/quick3dstateset.cpp \ $$PWD/quick3drendertargetselector.cpp \ - $$PWD/quick3dgeometry.cpp \ - $$PWD/quick3dbuffer.cpp \ $$PWD/quick3drendertargetoutput.cpp \ $$PWD/quick3dmemorybarrier.cpp \ $$PWD/quick3draycaster.cpp \ diff --git a/src/quick3d/quick3drender/items/quick3dbuffer.cpp b/src/quick3d/quick3drender/items/quick3dbuffer.cpp deleted file mode 100644 index 9ff349118..000000000 --- a/src/quick3d/quick3drender/items/quick3dbuffer.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -namespace Render { - -namespace Quick { - -namespace { -const int jsValueTypeId = qMetaTypeId(); -} - -Quick3DBuffer::Quick3DBuffer(Qt3DCore::QNode *parent) - : Qt3DRender::QBuffer(parent) - , m_engine(nullptr) - , m_v4engine(nullptr) -{ - QObject::connect(this, &Qt3DRender::QBuffer::dataChanged, this, &Quick3DBuffer::bufferDataChanged); -} - -QByteArray Quick3DBuffer::convertToRawData(const QJSValue &jsValue) -{ - initEngines(); - Q_ASSERT(m_v4engine); - QV4::Scope scope(m_v4engine); - QV4::Scoped typedArray(scope, - QJSValuePrivate::convertedToValue(m_v4engine, jsValue)); - if (!typedArray) - return QByteArray(); - - char *dataPtr = reinterpret_cast(typedArray->arrayData()->data()); - dataPtr += typedArray->d()->byteOffset; - uint byteLength = typedArray->byteLength(); - return QByteArray(dataPtr, byteLength); -} - -QVariant Quick3DBuffer::bufferData() const -{ - return QVariant::fromValue(data()); -} - -void Quick3DBuffer::setBufferData(const QVariant &bufferData) -{ - if (bufferData.userType() == QMetaType::QByteArray) { - QBuffer::setData(bufferData.toByteArray()); - } else if (bufferData.userType() == jsValueTypeId) { - QJSValue jsValue = bufferData.value(); - QBuffer::setData(convertToRawData(jsValue)); - } -} - -void Quick3DBuffer::updateData(int offset, const QVariant &bufferData) -{ - if (bufferData.userType() == QMetaType::QByteArray) { - QBuffer::updateData(offset, bufferData.toByteArray()); - } else if (bufferData.userType() == jsValueTypeId) { - QJSValue jsValue = bufferData.value(); - QBuffer::updateData(offset, convertToRawData(jsValue)); - } -} - -/*! - \qmlmethod string Quick3DBuffer::readBinaryFile(url &fileUrl) - - Reads the binary at \a fileUrl and return it as a QByteArray wrapped in a - QVariant - - \note this is provided as convenience for QML where reading files and creating - QByteArray is not possible - */ -QVariant Quick3DBuffer::readBinaryFile(const QUrl &fileUrl) -{ - QFile f(Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(fileUrl)); - QByteArray data; - - if (f.open(QIODevice::ReadOnly)) - data = f.readAll(); - return QVariant(data); -} - -void Quick3DBuffer::initEngines() -{ - if (m_engine == nullptr) { - m_engine = qmlEngine(parent()); - m_v4engine = QQmlEnginePrivate::getV4Engine(m_engine); - } -} - -} // Quick - -} // Render - -} // Qt3DRender - -QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dbuffer_p.h b/src/quick3d/quick3drender/items/quick3dbuffer_p.h deleted file mode 100644 index 233cc3faf..000000000 --- a/src/quick3d/quick3drender/items/quick3dbuffer_p.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_P_H -#define QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QQmlEngine; -class QJSValue; - -namespace QV4 { -struct ExecutionEngine; -} - -namespace Qt3DRender { - -namespace Render { - -namespace Quick { - -class Q_3DQUICKRENDERSHARED_PRIVATE_EXPORT Quick3DBuffer : public Qt3DRender::QBuffer -{ - Q_OBJECT - Q_PROPERTY(QVariant data READ bufferData WRITE setBufferData NOTIFY bufferDataChanged) -public: - explicit Quick3DBuffer(Qt3DCore::QNode *parent = nullptr); - - QVariant bufferData() const; - void setBufferData(const QVariant &bufferData); - - Q_INVOKABLE QVariant readBinaryFile(const QUrl &fileUrl); - -public Q_SLOTS: - void updateData(int offset, const QVariant &bytes); - -Q_SIGNALS: - void bufferDataChanged(); - -private: - QQmlEngine *m_engine; - QV4::ExecutionEngine *m_v4engine; - void initEngines(); - QByteArray convertToRawData(const QJSValue &jsValue); -}; - -} // Quick - -} // Render - -} // Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_P_H diff --git a/src/quick3d/quick3drender/items/quick3dgeometry.cpp b/src/quick3d/quick3drender/items/quick3dgeometry.cpp deleted file mode 100644 index 3f70ea572..000000000 --- a/src/quick3d/quick3drender/items/quick3dgeometry.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { -namespace Render { -namespace Quick { - -Quick3DGeometry::Quick3DGeometry(QObject *parent) - : QObject(parent) -{ -} - -QQmlListProperty Quick3DGeometry::attributeList() -{ - return QQmlListProperty(this, 0, - &Quick3DGeometry::appendAttribute, - &Quick3DGeometry::attributesCount, - &Quick3DGeometry::attributeAt, - &Quick3DGeometry::clearAttributes); -} - -void Quick3DGeometry::appendAttribute(QQmlListProperty *list, Qt3DRender::QAttribute *attribute) -{ - Quick3DGeometry *geometry = static_cast(list->object); - geometry->m_managedAttributes.append(attribute); - geometry->parentGeometry()->addAttribute(attribute); -} - -Qt3DRender::QAttribute *Quick3DGeometry::attributeAt(QQmlListProperty *list, int index) -{ - Quick3DGeometry *geometry = static_cast(list->object); - return geometry->parentGeometry()->attributes().at(index); -} - -int Quick3DGeometry::attributesCount(QQmlListProperty *list) -{ - Quick3DGeometry *geometry = static_cast(list->object); - return geometry->parentGeometry()->attributes().count(); -} - -void Quick3DGeometry::clearAttributes(QQmlListProperty *list) -{ - Quick3DGeometry *geometry = static_cast(list->object); - for (Qt3DRender::QAttribute *attribute : qAsConst(geometry->m_managedAttributes)) - geometry->parentGeometry()->removeAttribute(attribute); - geometry->m_managedAttributes.clear(); -} - -} // namespace Quick -} // namespace Render -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dgeometry_p.h b/src/quick3d/quick3drender/items/quick3dgeometry_p.h deleted file mode 100644 index 19a308076..000000000 --- a/src/quick3d/quick3drender/items/quick3dgeometry_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3D_QUICK3DGEOMETRY_P_H -#define QT3D_QUICK3DGEOMETRY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { -namespace Render { -namespace Quick { - -class Q_3DQUICKRENDERSHARED_PRIVATE_EXPORT Quick3DGeometry : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty attributes READ attributeList) - Q_CLASSINFO("DefaultProperty", "attributes") - -public: - explicit Quick3DGeometry(QObject *parent = 0); - inline QGeometry *parentGeometry() const { return qobject_cast(parent()); } - - QQmlListProperty attributeList(); - -private: - static void appendAttribute(QQmlListProperty *list, Qt3DRender::QAttribute *provider); - static Qt3DRender::QAttribute *attributeAt(QQmlListProperty *list, int index); - static int attributesCount(QQmlListProperty *list); - static void clearAttributes(QQmlListProperty *list); - - QVector m_managedAttributes; -}; - -} // namespace Quick -} // namespace Render -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3D_QUICK3DGEOMETRY_P_H diff --git a/src/quick3d/quick3dscene2d/items/scene2d.cpp b/src/quick3d/quick3dscene2d/items/scene2d.cpp index dcc99ed8c..2b0a6580d 100644 --- a/src/quick3d/quick3dscene2d/items/scene2d.cpp +++ b/src/quick3d/quick3dscene2d/items/scene2d.cpp @@ -480,7 +480,7 @@ void Scene2D::handlePickEvent(int type, const Qt3DRender::QPickEvent *ev) CoordinateReader reader(renderer()->nodeManagers()); if (reader.setGeometry(entity->renderComponent(), - QAttribute::defaultTextureCoordinateAttributeName())) { + Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName())) { Vector4D c0 = reader.getCoordinate(pickTriangle->vertex1Index()); Vector4D c1 = reader.getCoordinate(pickTriangle->vertex2Index()); Vector4D c2 = reader.getCoordinate(pickTriangle->vertex3Index()); diff --git a/src/render/backend/bufferutils_p.h b/src/render/backend/bufferutils_p.h index ea783df0d..83787b6bc 100644 --- a/src/render/backend/bufferutils_p.h +++ b/src/render/backend/bufferutils_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include +#include #include QT_BEGIN_NAMESPACE @@ -69,7 +69,7 @@ class Buffer; struct BufferInfo { BufferInfo() - : type(QAttribute::VertexBaseType::Float) + : type(Qt3DCore::QAttribute::VertexBaseType::Float) , dataSize(0) , count(0) , byteStride(0) @@ -79,7 +79,7 @@ struct BufferInfo {} QByteArray data; - QAttribute::VertexBaseType type; + Qt3DCore::QAttribute::VertexBaseType type; uint dataSize; uint count; uint byteStride; @@ -91,17 +91,17 @@ struct BufferInfo namespace BufferTypeInfo { - template struct EnumToType; - template <> struct EnumToType { typedef const char type; }; - template <> struct EnumToType { typedef const uchar type; }; - template <> struct EnumToType { typedef const short type; }; - template <> struct EnumToType { typedef const ushort type; }; - template <> struct EnumToType { typedef const int type; }; - template <> struct EnumToType { typedef const uint type; }; - template <> struct EnumToType { typedef const float type; }; - template <> struct EnumToType { typedef const double type; }; - - template + template struct EnumToType; + template <> struct EnumToType { typedef const char type; }; + template <> struct EnumToType { typedef const uchar type; }; + template <> struct EnumToType { typedef const short type; }; + template <> struct EnumToType { typedef const ushort type; }; + template <> struct EnumToType { typedef const int type; }; + template <> struct EnumToType { typedef const uint type; }; + template <> struct EnumToType { typedef const float type; }; + template <> struct EnumToType { typedef const double type; }; + + template typename EnumToType::type *castToType(const QByteArray &u, uint byteOffset) { return reinterpret_cast< typename EnumToType::type *>(u.constData() + byteOffset); diff --git a/src/render/backend/buffervisitor_p.h b/src/render/backend/buffervisitor_p.h index f3863f0a3..6d916208b 100644 --- a/src/render/backend/buffervisitor_p.h +++ b/src/render/backend/buffervisitor_p.h @@ -52,7 +52,7 @@ // #include -#include +#include #include #include #include @@ -72,7 +72,7 @@ namespace Qt3DRender { namespace Render { -template +template class Q_AUTOTEST_EXPORT BufferVisitor { public: @@ -137,20 +137,20 @@ public: if (indexAttribute) { auto indexData = m_manager->lookupResource(indexAttribute->bufferId())->data(); switch (indexAttribute->vertexBaseType()) { - case QAttribute::UnsignedShort: { - auto indexBuffer = BufferTypeInfo::castToType(indexData, indexAttribute->byteOffset()); + case Qt3DCore::QAttribute::UnsignedShort: { + auto indexBuffer = BufferTypeInfo::castToType(indexData, indexAttribute->byteOffset()); traverseCoordinateIndexed(vertexBuffer, indexBuffer, attribute->byteStride(), drawVertexCount, primitiveRestartEnabled, primitiveRestartIndex); break; } - case QAttribute::UnsignedInt: { - auto indexBuffer = BufferTypeInfo::castToType(indexData, indexAttribute->byteOffset()); + case Qt3DCore::QAttribute::UnsignedInt: { + auto indexBuffer = BufferTypeInfo::castToType(indexData, indexAttribute->byteOffset()); traverseCoordinateIndexed(vertexBuffer, indexBuffer, attribute->byteStride(), drawVertexCount, primitiveRestartEnabled, primitiveRestartIndex); break; } - case QAttribute::UnsignedByte: { - auto indexBuffer = BufferTypeInfo::castToType(indexData, indexAttribute->byteOffset()); + case Qt3DCore::QAttribute::UnsignedByte: { + auto indexBuffer = BufferTypeInfo::castToType(indexData, indexAttribute->byteOffset()); traverseCoordinateIndexed(vertexBuffer, indexBuffer, attribute->byteStride(), drawVertexCount, primitiveRestartEnabled, primitiveRestartIndex); break; @@ -292,7 +292,7 @@ protected: NodeManagers *m_manager; }; -typedef BufferVisitor Buffer3fVisitor; +typedef BufferVisitor Buffer3fVisitor; } // namespace Render diff --git a/src/render/backend/trianglesvisitor.cpp b/src/render/backend/trianglesvisitor.cpp index a58f2d20b..4cdf8a2bf 100644 --- a/src/render/backend/trianglesvisitor.cpp +++ b/src/render/backend/trianglesvisitor.cpp @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt3DCore; + namespace Qt3DRender { namespace Render { diff --git a/src/render/backend/trianglesvisitor_p.h b/src/render/backend/trianglesvisitor_p.h index d05eaef09..e8ac9bf27 100644 --- a/src/render/backend/trianglesvisitor_p.h +++ b/src/render/backend/trianglesvisitor_p.h @@ -52,7 +52,6 @@ // #include -#include #include #include #include diff --git a/src/render/backend/visitorutils_p.h b/src/render/backend/visitorutils_p.h index 14183e11b..3ea848c6b 100644 --- a/src/render/backend/visitorutils_p.h +++ b/src/render/backend/visitorutils_p.h @@ -61,17 +61,17 @@ namespace Render { namespace Visitor { -template struct EnumToType; -template <> struct EnumToType { typedef const char type; }; -template <> struct EnumToType { typedef const uchar type; }; -template <> struct EnumToType { typedef const short type; }; -template <> struct EnumToType { typedef const ushort type; }; -template <> struct EnumToType { typedef const int type; }; -template <> struct EnumToType { typedef const uint type; }; -template <> struct EnumToType { typedef const float type; }; -template <> struct EnumToType { typedef const double type; }; - -template +template struct EnumToType; +template <> struct EnumToType { typedef const char type; }; +template <> struct EnumToType { typedef const uchar type; }; +template <> struct EnumToType { typedef const short type; }; +template <> struct EnumToType { typedef const ushort type; }; +template <> struct EnumToType { typedef const int type; }; +template <> struct EnumToType { typedef const uint type; }; +template <> struct EnumToType { typedef const float type; }; +template <> struct EnumToType { typedef const double type; }; + +template inline typename EnumToType::type *castToType(const QByteArray &u, uint byteOffset) { return reinterpret_cast< typename EnumToType::type *>(u.constData() + byteOffset); @@ -81,21 +81,21 @@ template void processBuffer(const BufferInfo &info, Func &f) { switch (info.type) { - case QAttribute::Byte: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::Byte: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::UnsignedByte: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::UnsignedByte: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::Short: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::Short: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::UnsignedShort: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::UnsignedShort: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::Int: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::Int: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::UnsignedInt: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::UnsignedInt: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::Float: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::Float: f(info, castToType(info.data, info.byteOffset)); return; - case QAttribute::Double: f(info, castToType(info.data, info.byteOffset)); + case Qt3DCore::QAttribute::Double: f(info, castToType(info.data, info.byteOffset)); return; default: return; @@ -119,9 +119,9 @@ void visitPrimitives(NodeManagers *manager, const GeometryRenderer *renderer, Vi for (const Qt3DCore::QNodeId attrId : attrIds) { attribute = manager->lookupResource(attrId); if (attribute){ - if (!positionAttribute && attribute->name() == QAttribute::defaultPositionAttributeName()) + if (!positionAttribute && attribute->name() == Qt3DCore::QAttribute::defaultPositionAttributeName()) positionAttribute = attribute; - else if (attribute->attributeType() == QAttribute::IndexAttribute) + else if (attribute->attributeType() == Qt3DCore::QAttribute::IndexAttribute) indexAttribute = attribute; } } diff --git a/src/render/framegraph/qbuffercapture.h b/src/render/framegraph/qbuffercapture.h index e5073a308..5d148f2bf 100644 --- a/src/render/framegraph/qbuffercapture.h +++ b/src/render/framegraph/qbuffercapture.h @@ -41,7 +41,7 @@ #define QT3DRENDER_QBUFFERCAPTURE_H #include -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/render/frontend/qabstractfunctor.cpp b/src/render/frontend/qabstractfunctor.cpp deleted file mode 100644 index 698c3a291..000000000 --- a/src/render/frontend/qabstractfunctor.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qabstractfunctor.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -/*! - \class Qt3DRender::QAbstractFunctor - \inmodule Qt3DRender - \since 5.7 - \brief QAbstractFunctor is an abstract base class for all functors. - - The QAbstractFunctor is used as a base class for all functors and data - generators in Qt3DRender module. - - When user defines a new functor or generator, they need to implement the - \l QAbstractFunctor::id() method, which should be done using the \c {QT3D_FUNCTOR} - macro in the class definition. - */ -/*! - \fn qintptr Qt3DRender::QAbstractFunctor::id() const - - Returns a pointer to the id of the functor. - */ -/*! - \fn qintptr Qt3DRender::functorTypeId() - - Returns a pointer to the type id of the functor. -*/ -/*! - \macro QT3D_FUNCTOR(Class) - \relates Qt3DRender::QAbstractFunctor - - This macro assigns functor id to the \a Class, which is used by QAbstractFunctor::functor_cast - to determine if the cast can be done. - */ - -/*! - \fn template const T * Qt3DRender::QAbstractFunctor::functor_cast(const QAbstractFunctor *other) const - - This method is used to cast functor \a other to type T if the other is of - type T (or of subclass); otherwise returns 0. This method works similarly - to \l [QtCore] {qobject_cast(const QObject *object)}{qobject_cast()}, - except with functors derived from QAbstractFunctor. - - \warning If T was not declared with \l QT3D_FUNCTOR macro, then the results are undefined. - */ - -/*! Desctructor */ -QAbstractFunctor::~QAbstractFunctor() -{ - -} - -} // Qt3D - -QT_END_NAMESPACE - diff --git a/src/render/frontend/qabstractfunctor.h b/src/render/frontend/qabstractfunctor.h deleted file mode 100644 index 45492e141..000000000 --- a/src/render/frontend/qabstractfunctor.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QABSTRACTFUNCTOR_H -#define QT3DRENDER_QABSTRACTFUNCTOR_H - -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -// This will generate a unique id() function per type -// <=> 1 unique function address per type -template -struct FunctorType -{ - static qintptr id() - { - // The MSVC linker can under some cases optimize all the template - // functions into a single function. The code below is there to ensure - // that the linker won't collapse all these distincts functions into one - static T *t = nullptr; - return reinterpret_cast(t); - } -}; - -template -qintptr functorTypeId() -{ - return reinterpret_cast(&FunctorType::id); -} - -#define QT3D_FUNCTOR(Class) \ - qintptr id() const override { \ - return Qt3DRender::functorTypeId(); \ - } - - -class Q_3DRENDERSHARED_EXPORT QAbstractFunctor -{ -public: - QAbstractFunctor() = default; - virtual ~QAbstractFunctor(); - virtual qintptr id() const = 0; - - // TODO: Remove when moving a copy of this to Qt3DCore - template - const T *functor_cast(const QAbstractFunctor *other) const - { - if (other->id() == functorTypeId()) - return static_cast(other); - return nullptr; - } -private: - Q_DISABLE_COPY(QAbstractFunctor) -}; - -template -const T *functor_cast(const QAbstractFunctor *other) -{ - if (other->id() == functorTypeId()) - return static_cast(other); - return nullptr; -} - -} // Qt3D - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QABSTRACTFUNCTOR_H diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp index e929f532f..2e9b8e323 100644 --- a/src/render/frontend/qrenderaspect.cpp +++ b/src/render/frontend/qrenderaspect.cpp @@ -70,9 +70,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -170,7 +167,9 @@ #include #include - +#include +#include +#include #include #include #include @@ -267,13 +266,14 @@ void QRenderAspectPrivate::registerBackendTypes() { Q_Q(QRenderAspect); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); - qRegisterMetaType(); q->registerBackendType(QSharedPointer::create(m_renderer, m_nodeManagers)); q->registerBackendType(QSharedPointer >::create(m_renderer)); @@ -289,8 +289,8 @@ void QRenderAspectPrivate::registerBackendTypes() q->registerBackendType(QSharedPointer >::create(m_renderer)); // Geometry + Compute - q->registerBackendType(QSharedPointer >::create(m_renderer)); - q->registerBackendType(QSharedPointer::create(m_renderer, m_nodeManagers->bufferManager())); + q->registerBackendType(QSharedPointer >::create(m_renderer)); + q->registerBackendType(QSharedPointer::create(m_renderer, m_nodeManagers->bufferManager())); q->registerBackendType(QSharedPointer >::create(m_renderer)); q->registerBackendType(QSharedPointer >::create(m_renderer)); q->registerBackendType(QSharedPointer::create(m_renderer, m_nodeManagers->geometryRendererManager())); @@ -369,8 +369,8 @@ void QRenderAspectPrivate::unregisterBackendTypes() unregisterBackendType(); // Geometry + Compute - unregisterBackendType(); - unregisterBackendType(); + unregisterBackendType(); + unregisterBackendType(); unregisterBackendType(); unregisterBackendType(); unregisterBackendType(); diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri index 694b5cfc1..934672a01 100644 --- a/src/render/frontend/render-frontend.pri +++ b/src/render/frontend/render-frontend.pri @@ -1,7 +1,6 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qabstractfunctor.h \ $$PWD/qrenderaspect.h \ $$PWD/qrenderaspect_p.h \ $$PWD/qlayer.h \ @@ -33,7 +32,6 @@ HEADERS += \ $$PWD/qrendercapabilities_p.h SOURCES += \ - $$PWD/qabstractfunctor.cpp \ $$PWD/qrenderaspect.cpp \ $$PWD/sphere.cpp \ $$PWD/qlayer.cpp \ diff --git a/src/render/geometry/attribute.cpp b/src/render/geometry/attribute.cpp index de44c5fe3..b9e53b483 100644 --- a/src/render/geometry/attribute.cpp +++ b/src/render/geometry/attribute.cpp @@ -38,8 +38,7 @@ ****************************************************************************/ #include "attribute_p.h" -#include -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/render/geometry/attribute_p.h b/src/render/geometry/attribute_p.h index 87b3cbb4f..af776ae2c 100644 --- a/src/render/geometry/attribute_p.h +++ b/src/render/geometry/attribute_p.h @@ -52,7 +52,7 @@ // #include -#include +#include QT_BEGIN_NAMESPACE @@ -73,13 +73,13 @@ public: inline Qt3DCore::QNodeId bufferId() const { return m_bufferId; } inline QString name() const { return m_name; } inline int nameId() const { return m_nameId; } - inline QAttribute::VertexBaseType vertexBaseType() const { return m_vertexBaseType; } + inline Qt3DCore::QAttribute::VertexBaseType vertexBaseType() const { return m_vertexBaseType; } inline uint vertexSize() const { return m_vertexSize; } inline uint count() const { return m_count; } inline uint byteStride() const { return m_byteStride; } inline uint byteOffset() const { return m_byteOffset; } inline uint divisor() const { return m_divisor; } - inline QAttribute::AttributeType attributeType() const { return m_attributeType; } + inline Qt3DCore::QAttribute::AttributeType attributeType() const { return m_attributeType; } inline bool isDirty() const { return m_attributeDirty; } void unsetDirty(); @@ -87,13 +87,13 @@ private: Qt3DCore::QNodeId m_bufferId; QString m_name; int m_nameId; - QAttribute::VertexBaseType m_vertexBaseType; + Qt3DCore::QAttribute::VertexBaseType m_vertexBaseType; uint m_vertexSize; uint m_count; uint m_byteStride; uint m_byteOffset; uint m_divisor; - QAttribute::AttributeType m_attributeType; + Qt3DCore::QAttribute::AttributeType m_attributeType; bool m_attributeDirty; }; diff --git a/src/render/geometry/buffer.cpp b/src/render/geometry/buffer.cpp index 5b577b546..f7a1f376c 100644 --- a/src/render/geometry/buffer.cpp +++ b/src/render/geometry/buffer.cpp @@ -38,21 +38,19 @@ ****************************************************************************/ #include "buffer_p.h" +#include #include -#include QT_BEGIN_NAMESPACE -using namespace Qt3DCore; - namespace Qt3DRender { namespace Render { Buffer::Buffer() : BackendNode(QBackendNode::ReadWrite) - , m_usage(QBuffer::StaticDraw) + , m_usage(Qt3DCore::QBuffer::StaticDraw) , m_bufferDirty(false) - , m_access(QBuffer::Write) + , m_access(Qt3DCore::QBuffer::Write) , m_manager(nullptr) { // Maybe it could become read write if we want to inform @@ -65,11 +63,11 @@ Buffer::~Buffer() void Buffer::cleanup() { - m_usage = QBuffer::StaticDraw; + m_usage = Qt3DCore::QBuffer::StaticDraw; m_data.clear(); m_bufferUpdates.clear(); m_bufferDirty = false; - m_access = QBuffer::Write; + m_access = Qt3DCore::QBuffer::Write; } @@ -90,16 +88,16 @@ void Buffer::forceDataUpload() { // We push back an update with offset = -1 // As this is the way to force data to be loaded - QBufferUpdate updateNewData; + Qt3DCore::QBufferUpdate updateNewData; updateNewData.offset = -1; m_bufferUpdates.clear(); //previous updates are pointless m_bufferUpdates.push_back(updateNewData); } -void Buffer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) +void Buffer::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) { BackendNode::syncFromFrontEnd(frontEnd, firstTime); - const QBuffer *node = qobject_cast(frontEnd); + const Qt3DCore::QBuffer *node = qobject_cast(frontEnd); if (!node) return; @@ -128,17 +126,17 @@ void Buffer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) // if we enter this code block, there's no problem in actually // ignoring the partial updates if (v.isValid()) - const_cast(node)->setProperty("QT3D_updateData", {}); + const_cast(node)->setProperty("QT3D_updateData", {}); if (dirty && !m_data.isEmpty()) forceDataUpload(); } else if (v.isValid()) { // Apply partial updates and record them to allow partial upload to the GPU - Qt3DRender::QBufferUpdate updateData = v.value(); + Qt3DCore::QBufferUpdate updateData = v.value(); m_data.replace(updateData.offset, updateData.data.size(), updateData.data); m_bufferUpdates.push_back(updateData); m_bufferDirty = true; - const_cast(node)->setProperty("QT3D_updateData", {}); + const_cast(node)->setProperty("QT3D_updateData", {}); } } markDirty(AbstractRenderer::BuffersDirty); diff --git a/src/render/geometry/buffer_p.h b/src/render/geometry/buffer_p.h index c2e40ed88..28600581d 100644 --- a/src/render/geometry/buffer_p.h +++ b/src/render/geometry/buffer_p.h @@ -53,14 +53,15 @@ #include #include -#include +#include QT_BEGIN_NAMESPACE -namespace Qt3DRender { - -struct QBufferUpdate; +namespace Qt3DCore { + struct QBufferUpdate; +} +namespace Qt3DRender { namespace Render { class BufferManager; @@ -76,21 +77,21 @@ public: void setManager(BufferManager *manager); void updateDataFromGPUToCPU(QByteArray data); - inline QBuffer::UsageType usage() const { return m_usage; } + inline Qt3DCore::QBuffer::UsageType usage() const { return m_usage; } inline QByteArray data() const { return m_data; } - inline QVector &pendingBufferUpdates() { return m_bufferUpdates; } + inline QVector &pendingBufferUpdates() { return m_bufferUpdates; } inline bool isDirty() const { return m_bufferDirty; } - inline QBuffer::AccessType access() const { return m_access; } + inline Qt3DCore::QBuffer::AccessType access() const { return m_access; } void unsetDirty(); private: void forceDataUpload(); - QBuffer::UsageType m_usage; + Qt3DCore::QBuffer::UsageType m_usage; QByteArray m_data; - QVector m_bufferUpdates; + QVector m_bufferUpdates; bool m_bufferDirty; - QBuffer::AccessType m_access; + Qt3DCore::QBuffer::AccessType m_access; BufferManager *m_manager; }; @@ -107,7 +108,6 @@ private: }; } // namespace Render - } // namespace Qt3DRender QT_END_NAMESPACE diff --git a/src/render/geometry/geometry.cpp b/src/render/geometry/geometry.cpp index c70195ee0..22154e4f5 100644 --- a/src/render/geometry/geometry.cpp +++ b/src/render/geometry/geometry.cpp @@ -38,9 +38,9 @@ ****************************************************************************/ #include "geometry_p.h" -#include -#include -#include +#include +#include +#include #include diff --git a/src/render/geometry/geometry.pri b/src/render/geometry/geometry.pri index 88cc81b51..475f406d5 100644 --- a/src/render/geometry/geometry.pri +++ b/src/render/geometry/geometry.pri @@ -7,17 +7,10 @@ HEADERS += \ $$PWD/geometry_p.h \ $$PWD/geometryrenderer_p.h \ $$PWD/geometryrenderermanager_p.h \ - $$PWD/qbuffer.h \ - $$PWD/qbuffer_p.h \ - $$PWD/qgeometry.h \ - $$PWD/qgeometry_p.h \ - $$PWD/qgeometryfactory_p.h \ $$PWD/qgeometryrenderer.h \ $$PWD/qgeometryrenderer_p.h \ $$PWD/qmesh.h \ $$PWD/qmesh_p.h \ - $$PWD/qattribute_p.h \ - $$PWD/qattribute.h \ $$PWD/armature_p.h \ $$PWD/skeleton_p.h \ $$PWD/gltfskeletonloader_p.h \ @@ -31,11 +24,8 @@ SOURCES += \ $$PWD/geometry.cpp \ $$PWD/geometryrenderer.cpp \ $$PWD/geometryrenderermanager.cpp \ - $$PWD/qbuffer.cpp \ - $$PWD/qgeometry.cpp \ $$PWD/qgeometryrenderer.cpp \ $$PWD/qmesh.cpp \ - $$PWD/qattribute.cpp \ $$PWD/armature.cpp \ $$PWD/skeleton.cpp \ $$PWD/gltfskeletonloader.cpp \ diff --git a/src/render/geometry/geometryrenderer.cpp b/src/render/geometry/geometryrenderer.cpp index 7a726e03f..6f6227ba7 100644 --- a/src/render/geometry/geometryrenderer.cpp +++ b/src/render/geometry/geometryrenderer.cpp @@ -142,7 +142,7 @@ void GeometryRenderer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) if (m_geometryFactory && m_manager != nullptr) { m_manager->addDirtyGeometryRenderer(peerId()); - const bool isQMeshFunctor = m_geometryFactory->id() == Qt3DRender::functorTypeId(); + const bool isQMeshFunctor = m_geometryFactory->id() == Qt3DCore::functorTypeId(); if (isQMeshFunctor) { const QMesh *meshNode = static_cast(node); QMeshPrivate *dmeshNode = QMeshPrivate::get(const_cast(meshNode)); @@ -159,7 +159,7 @@ GeometryFunctorResult GeometryRenderer::executeFunctor() Q_ASSERT(m_geometryFactory); // What kind of functor are we dealing with? - const bool isQMeshFunctor = m_geometryFactory->id() == Qt3DRender::functorTypeId(); + const bool isQMeshFunctor = m_geometryFactory->id() == Qt3DCore::functorTypeId(); if (isQMeshFunctor) { QSharedPointer meshLoader = qSharedPointerCast(m_geometryFactory); @@ -171,7 +171,7 @@ GeometryFunctorResult GeometryRenderer::executeFunctor() if (meshLoader->downloaderService() == nullptr) { Qt3DCore::QServiceLocator *services = m_renderer->services(); meshLoader->setDownloaderService(services->service(Qt3DCore::QServiceLocator::DownloadHelperService)); - }; + } } // Load geometry diff --git a/src/render/geometry/geometryrenderer_p.h b/src/render/geometry/geometryrenderer_p.h index c5908ca01..87a289f7d 100644 --- a/src/render/geometry/geometryrenderer_p.h +++ b/src/render/geometry/geometryrenderer_p.h @@ -51,8 +51,8 @@ // We mean it. // +#include #include -#include #include #include @@ -69,7 +69,7 @@ class GeometryRendererManager; struct GeometryFunctorResult { - QGeometry *geometry; + Qt3DCore::QGeometry *geometry; QMesh::Status status; }; @@ -96,7 +96,7 @@ public: inline bool primitiveRestartEnabled() const { return m_primitiveRestartEnabled; } inline QGeometryRenderer::PrimitiveType primitiveType() const { return m_primitiveType; } inline bool isDirty() const { return m_dirty; } - inline QGeometryFactoryPtr geometryFactory() const { return m_geometryFactory; } + inline Qt3DCore::QGeometryFactoryPtr geometryFactory() const { return m_geometryFactory; } void unsetDirty(); // Build triangle data Job thread @@ -117,7 +117,7 @@ private: bool m_primitiveRestartEnabled; QGeometryRenderer::PrimitiveType m_primitiveType; bool m_dirty; - QGeometryFactoryPtr m_geometryFactory; + Qt3DCore::QGeometryFactoryPtr m_geometryFactory; GeometryRendererManager *m_manager; QVector m_triangleVolumes; }; diff --git a/src/render/geometry/gltfskeletonloader.cpp b/src/render/geometry/gltfskeletonloader.cpp index d5d344ce1..ce3b3a5f2 100644 --- a/src/render/geometry/gltfskeletonloader.cpp +++ b/src/render/geometry/gltfskeletonloader.cpp @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt3DCore; + namespace { void jsonArrayToSqt(const QJsonArray &jsonArray, Qt3DCore::Sqt &sqt) diff --git a/src/render/geometry/gltfskeletonloader_p.h b/src/render/geometry/gltfskeletonloader_p.h index b2a175ecb..b3e86a86c 100644 --- a/src/render/geometry/gltfskeletonloader_p.h +++ b/src/render/geometry/gltfskeletonloader_p.h @@ -49,7 +49,7 @@ // #include -#include +#include #include #include @@ -96,7 +96,7 @@ class GLTFSkeletonLoader explicit AccessorData(const QJsonObject &json); int bufferViewIndex; - QAttribute::VertexBaseType type; + Qt3DCore::QAttribute::VertexBaseType type; uint dataSize; int count; int byteOffset; @@ -139,8 +139,8 @@ public: SkeletonData createSkeleton(const QString &skeletonName); private: - static QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); - static uint accessorTypeSize(QAttribute::VertexBaseType componentType); + static Qt3DCore::QAttribute::VertexBaseType accessorTypeFromJSON(int componentType); + static uint accessorTypeSize(Qt3DCore::QAttribute::VertexBaseType componentType); static uint accessorDataSizeFromJson(const QString &type); struct RawData diff --git a/src/render/geometry/qattribute.cpp b/src/render/geometry/qattribute.cpp deleted file mode 100644 index 348695e45..000000000 --- a/src/render/geometry/qattribute.cpp +++ /dev/null @@ -1,493 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qattribute.h" -#include "qattribute_p.h" -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QAttributePrivate::QAttributePrivate() - : QNodePrivate() - , m_buffer(nullptr) - , m_name() - , m_vertexBaseType(QAttribute::Float) - , m_vertexSize(1) - , m_count(0) - , m_byteStride(0) - , m_byteOffset(0) - , m_divisor(0) - , m_attributeType(QAttribute::VertexAttribute) -{ -} - -/*! - * \qmltype Attribute - * \instantiates Qt3DRender::QAttribute - * \inqmlmodule Qt3D.Render - * \brief Defines an attribute and how data should be read from a Buffer. - * - * There are 3 types of attributes. - * \list - * \li VertexAttribute: used to define data to be read on a per vertex basis - * \li IndexAttribute: used to define vertex indices when indexed draw calls are - * to be used - *\li DrawIndirectAttribute: used to specify the DrawIndirect buffer to be used - * when indirect draw calls are to be used - * \endlist - * - * \note when an attribute is of type DrawIndirectAttribute, only count, stride - * and offset are relevant. - * - * When providing your own attributes, it may make sense to name your attribute - * using helpers such as QAttribute::defaultPositionAttributeName() as that - * will ensure your geometry will be compatible with picking and the various - * materials provided in the Qt3DExtras module. - */ - -/*! - * \class Qt3DRender::QAttribute - * \inheaderfile Qt3DRender/QAttribute - * \inmodule Qt3DRender - * - * \inherits Qt3DCore::QNode - * - * \brief Defines an attribute and how data should be read from a QBuffer. - * - * There are 3 types of attributes. - * \list - * \li VertexAttribute: used to define data to be read on a per vertex basis - * \li IndexAttribute: used to define vertex indices when indexed draw calls are - * to be used - *\li DrawIndirectAttribute: used to specify the DrawIndirect buffer to be used - * when indirect draw calls are to be used - * \endlist - * - * \note when an attribute is of type DrawIndirectAttribute, only count, stride - * and offset are relevant. - * - * When providing your own attributes, it may make sense to name your attribute - * using helpers such as QAttribute::defaultPositionAttributeName() as that - * will ensure your geometry will be compatible with picking and the various - * materials provided in the Qt3DExtras module. - * - * \sa QBuffer - */ - -/*! - * \typedef Qt3DRender::QBufferPtr - * \relates Qt3DRender::QAttribute - */ - -/*! - * \enum QAttribute::AttributeType - * - * The type of the attribute. - * - * \value VertexAttribute - * \value IndexAttribute - * \value DrawIndirectAttribute - */ - -/*! - * \enum QAttribute::VertexBaseType - * - * The type of the data. - * - * \value Byte - * \value UnsignedByte - * \value Short - * \value UnsignedShort - * \value Int - * \value UnsignedInt - * \value HalfFloat - * \value Float - * \value Double - */ - -/*! - * Constructs a new QAttribute with \a parent. - */ -QAttribute::QAttribute(QNode *parent) - : QNode(*new QAttributePrivate(), parent) -{ -} - -/*! - * Constructs a new QAttribute from \a buf of \a type, \a dataSize, \a count, \a offset, - * and \a stride with \a parent. - */ -QAttribute::QAttribute(QBuffer *buf, VertexBaseType type, uint dataSize, uint count, uint offset, uint stride, QNode *parent) - : QAttribute(parent) -{ - Q_D(QAttribute); - setBuffer(buf); - d->m_count = count; - d->m_byteOffset = offset; - d->m_vertexBaseType = type; - d->m_vertexSize = dataSize; - d->m_byteStride = stride; -} - - -/*! - * Constructs a new QAttribute named \a name from \a buf of \a type, \a - * dataSize, \a count, \a offset, and \a stride with \a parent. - */ -QAttribute::QAttribute(QBuffer *buf, const QString &name, VertexBaseType type, uint dataSize, uint count, uint offset, uint stride, QNode *parent) - : QAttribute(parent) -{ - Q_D(QAttribute); - setBuffer(buf); - d->m_name = name; - d->m_count = count; - d->m_byteOffset = offset; - d->m_vertexBaseType = type; - d->m_vertexSize = dataSize; - d->m_byteStride = stride; -} - -/*! \internal */ -QAttribute::~QAttribute() -{ -} - -/*! - * \property QAttribute::buffer - * - * Holds the buffer. - */ -QBuffer *QAttribute::buffer() const -{ - Q_D(const QAttribute); - return d->m_buffer; -} - -/*! - * \property QAttribute::name - * - * Holds the name. - */ -QString QAttribute::name() const -{ - Q_D(const QAttribute); - return d->m_name; -} - -/*! - * \property QAttribute::vertexSize - * - * Holds the data size, it can only be 1 to 4 units (scalars and vectors), - * 9 units (3x3 matrices) or 16 units (4x4 matrices). - */ -uint QAttribute::vertexSize() const -{ - Q_D(const QAttribute); - return d->m_vertexSize; -} - -/*! - * \property QAttribute::vertexBaseType - * - * Holds the data type. - */ -QAttribute::VertexBaseType QAttribute::vertexBaseType() const -{ - Q_D(const QAttribute); - return d->m_vertexBaseType; -} - -/*! - * \property QAttribute::count - * - * Holds the count. - */ -uint QAttribute::count() const -{ - Q_D(const QAttribute); - return d->m_count; -} - -/*! - * \property QAttribute::byteStride - * - * Holds the byte stride. - */ -uint QAttribute::byteStride() const -{ - Q_D(const QAttribute); - return d->m_byteStride; -} - -/*! - * \property QAttribute::byteOffset - * - * Holds the byte offset. - */ -uint QAttribute::byteOffset() const -{ - Q_D(const QAttribute); - return d->m_byteOffset; -} - -/*! - * \property QAttribute::divisor - * - * Holds the divisor. - */ -uint QAttribute::divisor() const -{ - Q_D(const QAttribute); - return d->m_divisor; -} - -/*! - * \property QAttribute::attributeType - * - * Holds the attribute type. - */ -QAttribute::AttributeType QAttribute::attributeType() const -{ - Q_D(const QAttribute); - return d->m_attributeType; -} - -void QAttribute::setBuffer(QBuffer *buffer) -{ - Q_D(QAttribute); - if (d->m_buffer == buffer) - return; - - if (d->m_buffer) - d->unregisterDestructionHelper(d->m_buffer); - - // We need to add it as a child of the current node if it has been declared inline - // Or not previously added as a child of the current node so that - // 1) The backend gets notified about it's creation - // 2) When the current node is destroyed, it gets destroyed as well - if (buffer && !buffer->parent()) - buffer->setParent(this); - - d->m_buffer = buffer; - - // Ensures proper bookkeeping - if (d->m_buffer) - d->registerDestructionHelper(d->m_buffer, &QAttribute::setBuffer, d->m_buffer); - - emit bufferChanged(buffer); -} - -void QAttribute::setName(const QString &name) -{ - Q_D(QAttribute); - if (d->m_name == name) - return; - - d->m_name = name; - emit nameChanged(name); -} - -void QAttribute::setVertexBaseType(VertexBaseType type) -{ - Q_D(QAttribute); - - if (d->m_vertexBaseType == type) - return; - - d->m_vertexBaseType = type; - emit vertexBaseTypeChanged(type); - emit dataTypeChanged(type); -} - -void QAttribute::setVertexSize(uint size) -{ - Q_D(QAttribute); - if (d->m_vertexSize == size) - return; - Q_ASSERT((size >= 1 && size <= 4) || (size == 9) || (size == 16)); - d->m_vertexSize = size; - emit vertexSizeChanged(size); - emit dataSizeChanged(size); -} - -void QAttribute::setCount(uint count) -{ - Q_D(QAttribute); - if (d->m_count == count) - return; - - d->m_count = count; - emit countChanged(count); -} - -void QAttribute::setByteStride(uint byteStride) -{ - Q_D(QAttribute); - if (d->m_byteStride == byteStride) - return; - - d->m_byteStride = byteStride; - emit byteStrideChanged(byteStride); -} - -void QAttribute::setByteOffset(uint byteOffset) -{ - Q_D(QAttribute); - if (d->m_byteOffset == byteOffset) - return; - - d->m_byteOffset = byteOffset; - emit byteOffsetChanged(byteOffset); -} - -void QAttribute::setDivisor(uint divisor) -{ - Q_D(QAttribute); - if (d->m_divisor == divisor) - return; - - d->m_divisor = divisor; - emit divisorChanged(divisor); -} - -void QAttribute::setAttributeType(AttributeType attributeType) -{ - Q_D(QAttribute); - if (d->m_attributeType == attributeType) - return; - - d->m_attributeType = attributeType; - emit attributeTypeChanged(attributeType); -} -/*! - * \brief QAttribute::defaultPositionAttributeName - * \return the name of the default position attribute - */ -QString QAttribute::defaultPositionAttributeName() -{ - return QStringLiteral("vertexPosition"); -} -/*! - * \brief QAttribute::defaultNormalAttributeName - * \return the name of the default normal attribute - */ -QString QAttribute::defaultNormalAttributeName() -{ - return QStringLiteral("vertexNormal"); -} -/*! - * \brief QAttribute::defaultColorAttributeName - * \return the name of the default color attribute - */ -QString QAttribute::defaultColorAttributeName() -{ - return QStringLiteral("vertexColor"); -} -/*! - * \brief QAttribute::defaultTextureCoordinateAttributeName - * \return the name of the default texture coordinate attribute - */ -QString QAttribute::defaultTextureCoordinateAttributeName() -{ - return QStringLiteral("vertexTexCoord"); -} -/*! - * \brief QAttribute::defaultTangentAttributeName - * \return the name of the default tangent attribute - */ -QString QAttribute::defaultTangentAttributeName() -{ - return QStringLiteral("vertexTangent"); -} - -/*! - * \brief QAttribute::defaultJointIndicesAttributeName - * \return the name of the default joint indices attribute - */ -QString QAttribute::defaultJointIndicesAttributeName() -{ - return QStringLiteral("vertexJointIndices"); -} - -/*! - * \brief QAttribute::defaultJointIndicesAttributeName - * \return the name of the default joint weights attribute - */ -QString QAttribute::defaultJointWeightsAttributeName() -{ - return QStringLiteral("vertexJointWeights"); -} - -/*! - * \brief QAttribute::defaultTextureCoordinate1AttributeName - * \return the name of the default attribute for the second layer of texture - * coordinates - */ -QString QAttribute::defaultTextureCoordinate1AttributeName() -{ - return QStringLiteral("vertexTexCoord1"); -} - -/*! - * \brief QAttribute::defaultTextureCoordinate2AttributeName - * \return the name of the default attribute for the third layer of texture - * coordinates - */ -QString QAttribute::defaultTextureCoordinate2AttributeName() -{ - return QStringLiteral("vertexTexCoord2"); -} - -/*! -\fn Qt3DRender::QAttribute::dataSizeChanged(uint vertexSize) - -The signal is emitted with \a vertexSize when the dataSize changes. -*/ -/*! -\fn Qt3DRender::QAttribute::dataTypeChanged(Qt3DRender::QAttribute::VertexBaseType vertexBaseType) - -The signal is emitted with \a vertexBaseType when the dataType changed. -*/ - - -} // Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/geometry/qattribute.h b/src/render/geometry/qattribute.h deleted file mode 100644 index ec3b65f32..000000000 --- a/src/render/geometry/qattribute.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QATTRIBUTE_H -#define QT3DRENDER_QATTRIBUTE_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QBuffer; -class QAttributePrivate; - -typedef QSharedPointer QBufferPtr; - -class Q_3DRENDERSHARED_EXPORT QAttribute : public Qt3DCore::QNode -{ - Q_OBJECT - Q_PROPERTY(Qt3DRender::QBuffer *buffer READ buffer WRITE setBuffer NOTIFY bufferChanged) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(VertexBaseType vertexBaseType READ vertexBaseType WRITE setVertexBaseType NOTIFY vertexBaseTypeChanged) - Q_PROPERTY(uint vertexSize READ vertexSize WRITE setVertexSize NOTIFY vertexSizeChanged) - Q_PROPERTY(uint count READ count WRITE setCount NOTIFY countChanged) - Q_PROPERTY(uint byteStride READ byteStride WRITE setByteStride NOTIFY byteStrideChanged) - Q_PROPERTY(uint byteOffset READ byteOffset WRITE setByteOffset NOTIFY byteOffsetChanged) - Q_PROPERTY(uint divisor READ divisor WRITE setDivisor NOTIFY divisorChanged) - Q_PROPERTY(AttributeType attributeType READ attributeType WRITE setAttributeType NOTIFY attributeTypeChanged) - Q_PROPERTY(QString defaultPositionAttributeName READ defaultPositionAttributeName CONSTANT) - Q_PROPERTY(QString defaultNormalAttributeName READ defaultNormalAttributeName CONSTANT) - Q_PROPERTY(QString defaultColorAttributeName READ defaultColorAttributeName CONSTANT) - Q_PROPERTY(QString defaultTextureCoordinateAttributeName READ defaultTextureCoordinateAttributeName CONSTANT) - Q_PROPERTY(QString defaultTextureCoordinate1AttributeName READ defaultTextureCoordinate1AttributeName CONSTANT REVISION 11) - Q_PROPERTY(QString defaultTextureCoordinate2AttributeName READ defaultTextureCoordinate2AttributeName CONSTANT REVISION 11) - Q_PROPERTY(QString defaultTangentAttributeName READ defaultTangentAttributeName CONSTANT) - Q_PROPERTY(QString defaultJointIndicesAttributeName READ defaultJointIndicesAttributeName CONSTANT REVISION 10) - Q_PROPERTY(QString defaultJointWeightsAttributeName READ defaultJointWeightsAttributeName CONSTANT REVISION 10) - -public: - enum AttributeType { - VertexAttribute, - IndexAttribute, - DrawIndirectAttribute - }; - - Q_ENUM(AttributeType) // LCOV_EXCL_LINE - - enum VertexBaseType { - Byte = 0, - UnsignedByte, - Short, - UnsignedShort, - Int, - UnsignedInt, - HalfFloat, - Float, - Double - }; - Q_ENUM(VertexBaseType) // LCOV_EXCL_LINE - - explicit QAttribute(QNode *parent = nullptr); - explicit QAttribute(QBuffer *buf, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); - explicit QAttribute(QBuffer *buf, const QString &name, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); - ~QAttribute(); - - QBuffer *buffer() const; - QString name() const; - VertexBaseType vertexBaseType() const; - uint vertexSize() const; - uint count() const; - uint byteStride() const; - uint byteOffset() const; - uint divisor() const; - AttributeType attributeType() const; - - Q_INVOKABLE static QString defaultPositionAttributeName(); - Q_INVOKABLE static QString defaultNormalAttributeName(); - Q_INVOKABLE static QString defaultColorAttributeName(); - Q_INVOKABLE static QString defaultTextureCoordinateAttributeName(); - Q_INVOKABLE static QString defaultTangentAttributeName(); - static QString defaultJointIndicesAttributeName(); - static QString defaultJointWeightsAttributeName(); - static QString defaultTextureCoordinate1AttributeName(); - static QString defaultTextureCoordinate2AttributeName(); - -public Q_SLOTS: - void setBuffer(QBuffer *buffer); - void setName(const QString &name); - void setVertexBaseType(VertexBaseType type); - void setVertexSize(uint size); - void setCount(uint count); - void setByteStride(uint byteStride); - void setByteOffset(uint byteOffset); - void setDivisor(uint divisor); - void setAttributeType(AttributeType attributeType); - -Q_SIGNALS: - void bufferChanged(QBuffer *buffer); - void nameChanged(const QString &name); - void vertexBaseTypeChanged(VertexBaseType vertexBaseType); - void vertexSizeChanged(uint vertexSize); - void dataTypeChanged(VertexBaseType vertexBaseType); - void dataSizeChanged(uint vertexSize); - void countChanged(uint count); - void byteStrideChanged(uint byteStride); - void byteOffsetChanged(uint byteOffset); - void divisorChanged(uint divisor); - void attributeTypeChanged(AttributeType attributeType); - -private: - Q_DECLARE_PRIVATE(QAttribute) -}; - -} // Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QATTRIBUTE_H diff --git a/src/render/geometry/qattribute_p.h b/src/render/geometry/qattribute_p.h deleted file mode 100644 index fd6936e0d..000000000 --- a/src/render/geometry/qattribute_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QATTRIBUTE_P_H -#define QT3DRENDER_QATTRIBUTE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QAttribute; - -class Q_3DRENDERSHARED_PRIVATE_EXPORT QAttributePrivate : public Qt3DCore::QNodePrivate -{ -public: - Q_DECLARE_PUBLIC(QAttribute) - - QAttributePrivate(); - - QBuffer *m_buffer; - QString m_name; - QAttribute::VertexBaseType m_vertexBaseType; - uint m_vertexSize; - uint m_count; - uint m_byteStride; - uint m_byteOffset; - uint m_divisor; - QAttribute::AttributeType m_attributeType; -}; - -} // Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QATTRIBUTE_P_H diff --git a/src/render/geometry/qbuffer.cpp b/src/render/geometry/qbuffer.cpp deleted file mode 100644 index 58ff304a0..000000000 --- a/src/render/geometry/qbuffer.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbuffer.h" -#include "qbuffer_p.h" -#include - -QT_BEGIN_NAMESPACE - -using namespace Qt3DCore; - -namespace Qt3DRender { - -QBufferPrivate::QBufferPrivate() - : QNodePrivate() - , m_type(QBuffer::VertexBuffer) - , m_usage(QBuffer::StaticDraw) - , m_access(QBuffer::Write) -{ -} - -void QBufferPrivate::setData(const QByteArray &data) -{ - Q_Q(QBuffer); - const bool blocked = q->blockNotifications(true); - m_data = data; - emit q->dataChanged(data); - q->blockNotifications(blocked); -} - -/*! - * \qmltype Buffer - * \instantiates Qt3DRender::QBuffer - * \inqmlmodule Qt3D.Render - * - * \brief Provides a data store for raw data to later be used as vertices or - * uniforms. - */ - -/*! - * \qmlproperty QBuffer::UsageType Buffer::usage - * - * Holds the buffer usage. - */ - -/*! - * \qmlproperty QBuffer::BufferType Buffer::type - * - * Holds the buffer type. - * - * \deprecated - */ - -/*! - * \class Qt3DRender::QBuffer - * \inheaderfile Qt3DRender/QBuffer - * \inmodule Qt3DRender - * - * \inherits Qt3DCore::QNode - * - * \brief Provides a data store for raw data to later be used as vertices or - * uniforms. - * - * Data can be provided directly using QBuffer::setData(). - */ - -/*! - * \fn void Qt3DRender::QBuffer::dataChanged(const QByteArray &bytes) - * - * This signal is emitted with \a bytes when data changes. - */ - -/*! - * \fn void Qt3DRender::QBuffer::dataAvailable() - * - * This signal is emitted when data becomes available. - */ - -/*! - * \enum QBuffer::BufferType - * - * The type of the buffer. - * - * \value VertexBuffer - * GL_ARRAY_BUFFER - * \value IndexBuffer - * GL_ELEMENT_ARRAY_BUFFER - * \value PixelPackBuffer - * GL_PIXEL_PACK_BUFFER - * \value PixelUnpackBuffer - * GL_PIXEL_UNPACK_BUFFER - * \value UniformBuffer - * GL_UNIFORM_BUFFER - * \value ShaderStorageBuffer - * GL_SHADER_STORAGE_BUFFER - * \value DrawIndirectBuffer - * GL_DRAW_INDIRECT_BUFFER - * - * \deprecated - */ - -/*! - * \enum QBuffer::UsageType - * - * The type of the usage. - * - * \value StreamDraw - * GL_STREAM_DRAW - * \value StreamRead - * GL_STREAM_READ - * \value StreamCopy - * GL_STREAM_COPY - * \value StaticDraw - * GL_STATIC_DRAW - * \value StaticRead - * GL_STATIC_READ - * \value StaticCopy - * GL_STATIC_COPY - * \value DynamicDraw - * GL_DYNAMIC_DRAW - * \value DynamicRead - * GL_DYNAMIC_READ - * \value DynamicCopy - * GL_DYNAMIC_COPY - */ - -/*! - * \enum QBuffer::AccessType - * - * \value Write - * Write access - * \value Read - * Read access - * \value ReadWrite - * Write|Read - */ - -/*! - * \typedef Qt3DRender::QBufferDataGeneratorPtr - * \relates Qt3DRender::QBuffer - */ - -/*! - * Constructs a new QBuffer with \a parent. - */ -QBuffer::QBuffer(QNode *parent) - : QNode(*new QBufferPrivate(), parent) -{ -} - -/*! - * Constructs a new QBuffer of buffer type \a ty with \a parent. - * - * \deprecated - */ -QBuffer::QBuffer(QBuffer::BufferType ty, QNode *parent) - : QNode(*new QBufferPrivate(), parent) -{ - Q_D(QBuffer); - d->m_type = ty; -} - -/*! - * \internal - */ -QBuffer::~QBuffer() -{ -} - -/*! - * Sets \a bytes as data. - */ -void QBuffer::setData(const QByteArray &bytes) -{ - Q_D(QBuffer); - if (bytes != d->m_data) { - d->setData(bytes); - d->update(); - } -} - -/*! - * Updates the data by replacing it with \a bytes at \a offset. - */ -void QBuffer::updateData(int offset, const QByteArray &bytes) -{ - Q_D(QBuffer); - Q_ASSERT(offset >= 0 && (offset + bytes.size()) <= d->m_data.size()); - - // Update data - d->m_data.replace(offset, bytes.size(), bytes); - const bool blocked = blockNotifications(true); - emit dataChanged(d->m_data); - blockNotifications(blocked); - - QBufferUpdate updateData; - updateData.offset = offset; - updateData.data = bytes; - setProperty("QT3D_updateData", QVariant::fromValue(updateData)); - d->update(); -} - -/*! - * \return the data. - */ -QByteArray QBuffer::data() const -{ - Q_D(const QBuffer); - return d->m_data; -} - -/*! - * \property QBuffer::usage - * - * Holds the buffer usage. - */ -QBuffer::UsageType QBuffer::usage() const -{ - Q_D(const QBuffer); - return d->m_usage; -} - -void QBuffer::setUsage(QBuffer::UsageType usage) -{ - Q_D(QBuffer); - if (usage != d->m_usage) { - d->m_usage = usage; - emit usageChanged(usage); - } -} - -/*! - * \property QBuffer::type - * - * Holds the buffer type. - * - * \deprecated - */ -QBuffer::BufferType QBuffer::type() const -{ - Q_D(const QBuffer); - return d->m_type; -} - -void QBuffer::setAccessType(QBuffer::AccessType access) -{ - Q_D(QBuffer); - if (d->m_access != access) { - d->m_access = access; - Q_EMIT accessTypeChanged(access); - } -} - -/*! - * \property Qt3DRender::QBuffer::accessType - * - * Returns the \l {QBuffer::}{AccessType} of the buffer. - * - * \sa QBuffer::AccessType - */ -QBuffer::AccessType QBuffer::accessType() const -{ - Q_D(const QBuffer); - return d->m_access; -} - -void QBuffer::setType(QBuffer::BufferType type) -{ - Q_D(QBuffer); - if (type != d->m_type) { - d->m_type = type; - emit typeChanged(type); - } -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/geometry/qbuffer.h b/src/render/geometry/qbuffer.h deleted file mode 100644 index fceeea2dc..000000000 --- a/src/render/geometry/qbuffer.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QBUFFER_H -#define QT3DRENDER_QBUFFER_H - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QBufferPrivate; - -class Q_3DRENDERSHARED_EXPORT QBuffer : public Qt3DCore::QNode -{ - Q_OBJECT - Q_PROPERTY(BufferType type READ type WRITE setType NOTIFY typeChanged) - Q_PROPERTY(UsageType usage READ usage WRITE setUsage NOTIFY usageChanged) - Q_PROPERTY(AccessType accessType READ accessType WRITE setAccessType NOTIFY accessTypeChanged REVISION 9) - -public: - enum BufferType - { - VertexBuffer = 0x8892, // GL_ARRAY_BUFFER - IndexBuffer = 0x8893, // GL_ELEMENT_ARRAY_BUFFER - PixelPackBuffer = 0x88EB, // GL_PIXEL_PACK_BUFFER - PixelUnpackBuffer = 0x88EC, // GL_PIXEL_UNPACK_BUFFER - UniformBuffer = 0x8A11, // GL_UNIFORM_BUFFER - ShaderStorageBuffer = 0x90D2, // GL_SHADER_STORAGE_BUFFER - DrawIndirectBuffer = 0x8F3F // GL_DRAW_INDIRECT_BUFFER - }; - Q_ENUM(BufferType) // LCOV_EXCL_LINE - - enum UsageType - { - StreamDraw = 0x88E0, // GL_STREAM_DRAW - StreamRead = 0x88E1, // GL_STREAM_READ - StreamCopy = 0x88E2, // GL_STREAM_COPY - StaticDraw = 0x88E4, // GL_STATIC_DRAW - StaticRead = 0x88E5, // GL_STATIC_READ - StaticCopy = 0x88E6, // GL_STATIC_COPY - DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW - DynamicRead = 0x88E9, // GL_DYNAMIC_READ - DynamicCopy = 0x88EA // GL_DYNAMIC_COPY - }; - Q_ENUM(UsageType) // LCOV_EXCL_LINE - - enum AccessType { - Write = 0x1, - Read = 0x2, - ReadWrite = Write|Read - }; - Q_ENUM(AccessType) // LCOV_EXCL_LINE - - explicit QBuffer(Qt3DCore::QNode *parent = nullptr); - QT_DEPRECATED explicit QBuffer(BufferType ty, Qt3DCore::QNode *parent = nullptr); - ~QBuffer(); - - UsageType usage() const; - QT_DEPRECATED BufferType type() const; - AccessType accessType() const; - - void setData(const QByteArray &bytes); - QByteArray data() const; - - Q_INVOKABLE void updateData(int offset, const QByteArray &bytes); - -public Q_SLOTS: - QT_DEPRECATED void setType(BufferType type); - void setUsage(UsageType usage); - void setAccessType(AccessType access); - -Q_SIGNALS: - void dataChanged(const QByteArray &bytes); - void typeChanged(BufferType type); - void usageChanged(UsageType usage); - void accessTypeChanged(AccessType access); - void dataAvailable(); - -private: - Q_DECLARE_PRIVATE(QBuffer) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QBUFFER_H diff --git a/src/render/geometry/qbuffer_p.h b/src/render/geometry/qbuffer_p.h deleted file mode 100644 index b6d6318b4..000000000 --- a/src/render/geometry/qbuffer_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QBUFFER_P_H -#define QT3DRENDER_QBUFFER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class Q_3DRENDERSHARED_EXPORT QBufferPrivate : public Qt3DCore::QNodePrivate -{ -public: - Q_DECLARE_PUBLIC(QBuffer) - - QBufferPrivate(); - - QByteArray m_data; - QBuffer::BufferType m_type; - QBuffer::UsageType m_usage; - QBuffer::AccessType m_access; - - void setData(const QByteArray &data); -}; - -struct QBufferUpdate -{ - int offset; - QByteArray data; -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE -Q_DECLARE_METATYPE(Qt3DRender::QBufferUpdate) // LCOV_EXCL_LINE - -#endif // QT3DRENDER_QBUFFER_P_H diff --git a/src/render/geometry/qgeometry.cpp b/src/render/geometry/qgeometry.cpp deleted file mode 100644 index b3992b0aa..000000000 --- a/src/render/geometry/qgeometry.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgeometry.h" -#include "qgeometryfactory_p.h" -#include "qgeometry_p.h" -#include -#include - -QT_BEGIN_NAMESPACE - -using namespace Qt3DCore; - -namespace Qt3DRender { - -QGeometryFactory::~QGeometryFactory() -{ -} - -QGeometryPrivate::QGeometryPrivate() - : QNodePrivate(), - m_boundingVolumePositionAttribute(nullptr) -{ -} - -QGeometryPrivate::~QGeometryPrivate() -{ -} - -void QGeometryPrivate::setExtent(const QVector3D &minExtent, const QVector3D &maxExtent) -{ - Q_Q(QGeometry); - if (m_minExtent != minExtent) { - m_minExtent = minExtent; - emit q->minExtentChanged(minExtent); - } - - if (m_maxExtent != maxExtent) { - m_maxExtent = maxExtent; - emit q->maxExtentChanged(maxExtent); - } -} - -/*! - \qmltype Geometry - \instantiates Qt3DRender::QGeometry - \inqmlmodule Qt3D.Render - \inherits Node - \since 5.7 - \brief Encapsulates geometry. - - A Geometry type is used to group a list of Attribute objects together - to form a geometric shape Qt3D is able to render using GeometryRenderer. - Special attribute can be set in order to calculate bounding volume of the shape. - */ - -/*! - \class Qt3DRender::QGeometry - \inmodule Qt3DRender - \since 5.7 - \brief Encapsulates geometry. - - A Qt3DRender::QGeometry class is used to group a list of Qt3DRender::QAttribute - objects together to form a geometric shape Qt3D is able to render using - Qt3DRender::QGeometryRenderer. Special attribute can be set in order to calculate - bounding volume of the shape. - */ - -/*! - \qmlproperty Attribute Geometry::boundingVolumePositionAttribute - - Holds the attribute used to compute the bounding volume. The bounding volume is used internally - for picking and view frustum culling. - - If unspecified, the system will look for the attribute using the name returned by - QAttribute::defaultPositionAttributeName. - - \sa Attribute - */ -/*! - \qmlproperty list Geometry::attributes - - Holds the list of attributes the geometry comprises of. - */ - -/*! - \property QGeometry::boundingVolumePositionAttribute - - Holds the attribute used to compute the bounding volume. The bounding volume is used internally - for picking and view frustum culling. - - If unspecified, the system will look for the attribute using the name returned by - QAttribute::defaultPositionAttributeName. - - \sa Qt3DRender::QAttribute - */ - - -/*! - Constructs a new QGeometry with \a parent. - */ -QGeometry::QGeometry(QNode *parent) - : QGeometry(*new QGeometryPrivate(), parent) {} - -/*! - \fn Qt3DRender::QGeometryFactory::operator()() - - Returns the generated geometry. -*/ -/*! - \fn bool Qt3DRender::QGeometryFactory::operator==(const QGeometryFactory &other) const = 0 - - Compares the factory with the factory specified in \a other. - Returns true if they are equal. -*/ -/*! - \internal - */ -QGeometry::~QGeometry() -{ -} - -/*! - \internal - */ -QGeometry::QGeometry(QGeometryPrivate &dd, QNode *parent) - : QNode(dd, parent) -{ -} - -/*! - \fn void Qt3DRender::QGeometry::addAttribute(Qt3DRender::QAttribute *attribute) - Adds an \a attribute to this geometry. - */ -void QGeometry::addAttribute(QAttribute *attribute) -{ - Q_ASSERT(attribute); - Q_D(QGeometry); - if (!d->m_attributes.contains(attribute)) { - d->m_attributes.append(attribute); - - // Ensures proper bookkeeping - d->registerDestructionHelper(attribute, &QGeometry::removeAttribute, d->m_attributes); - - // We need to add it as a child of the current node if it has been declared inline - // Or not previously added as a child of the current node so that - // 1) The backend gets notified about it's creation - // 2) When the current node is destroyed, it gets destroyed as well - if (!attribute->parent()) - attribute->setParent(this); - - d->update(); - } -} - -/*! - \fn void Qt3DRender::QGeometry::removeAttribute(Qt3DRender::QAttribute *attribute) - Removes the given \a attribute from this geometry. - */ -void QGeometry::removeAttribute(QAttribute *attribute) -{ - Q_ASSERT(attribute); - Q_D(QGeometry); - d->m_attributes.removeOne(attribute); - // Remove bookkeeping connection - d->unregisterDestructionHelper(attribute); - d->update(); -} - -void QGeometry::setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute) -{ - Q_D(QGeometry); - if (d->m_boundingVolumePositionAttribute != boundingVolumePositionAttribute) { - d->m_boundingVolumePositionAttribute = boundingVolumePositionAttribute; - emit boundingVolumePositionAttributeChanged(boundingVolumePositionAttribute); - } -} - -QAttribute *QGeometry::boundingVolumePositionAttribute() const -{ - Q_D(const QGeometry); - return d->m_boundingVolumePositionAttribute; -} - -/*! - \qmlproperty vector3d Geometry::minExtent - - Holds the vertex with the lowest x, y, z position values. - */ - -/*! - \property QGeometry::minExtent - - Holds the vertex with the lowest x, y, z position values. - */ -QVector3D QGeometry::minExtent() const -{ - Q_D(const QGeometry); - return d->m_minExtent; -} - -/*! - \qmlproperty vector3d Geometry::maxExtent - - Holds the vertex with the highest x, y, z position values. - */ - -/*! - \property QGeometry::maxExtent - - Holds the vertex with the highest x, y, z position values. - */ -QVector3D QGeometry::maxExtent() const -{ - Q_D(const QGeometry); - return d->m_maxExtent; -} - -/*! - Returns the list of attributes in this geometry. - */ -QVector QGeometry::attributes() const -{ - Q_D(const QGeometry); - return d->m_attributes; -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#include "moc_qgeometry.cpp" diff --git a/src/render/geometry/qgeometry.h b/src/render/geometry/qgeometry.h deleted file mode 100644 index 442ec7d7a..000000000 --- a/src/render/geometry/qgeometry.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QGEOMETRY_H -#define QT3DRENDER_QGEOMETRY_H - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QAttribute; -class QGeometryPrivate; - -class Q_3DRENDERSHARED_EXPORT QGeometry : public Qt3DCore::QNode -{ - Q_OBJECT - Q_PROPERTY(Qt3DRender::QAttribute *boundingVolumePositionAttribute READ boundingVolumePositionAttribute WRITE setBoundingVolumePositionAttribute NOTIFY boundingVolumePositionAttributeChanged) - Q_PROPERTY(QVector3D minExtent READ minExtent NOTIFY minExtentChanged REVISION 13) - Q_PROPERTY(QVector3D maxExtent READ maxExtent NOTIFY maxExtentChanged REVISION 13) -public: - explicit QGeometry(Qt3DCore::QNode *parent = nullptr); - ~QGeometry(); - - QVector attributes() const; - Q_INVOKABLE void addAttribute(Qt3DRender::QAttribute *attribute); - Q_INVOKABLE void removeAttribute(Qt3DRender::QAttribute *attribute); - - QAttribute *boundingVolumePositionAttribute() const; - QVector3D minExtent() const; - QVector3D maxExtent() const; - -public Q_SLOTS: - void setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute); - -Q_SIGNALS: - void boundingVolumePositionAttributeChanged(QAttribute *boundingVolumePositionAttribute); - Q_REVISION(13) void minExtentChanged(const QVector3D &minExtent); - Q_REVISION(13) void maxExtentChanged(const QVector3D &maxExtent); -protected: - explicit QGeometry(QGeometryPrivate &dd, Qt3DCore::QNode *parent = nullptr); - -private: - Q_DECLARE_PRIVATE(QGeometry) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QGEOMETRY_H diff --git a/src/render/geometry/qgeometry_p.h b/src/render/geometry/qgeometry_p.h deleted file mode 100644 index 2b271292d..000000000 --- a/src/render/geometry/qgeometry_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3D_QGEOMETRY_P_H -#define QT3D_QGEOMETRY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class Q_3DRENDERSHARED_PRIVATE_EXPORT QGeometryPrivate : public Qt3DCore::QNodePrivate -{ -public: - Q_DECLARE_PUBLIC(QGeometry) - QGeometryPrivate(); - ~QGeometryPrivate(); - - void setExtent(const QVector3D &minExtent, const QVector3D &maxExtent); - - - QVector m_attributes; - QAttribute *m_boundingVolumePositionAttribute; - QVector3D m_minExtent; - QVector3D m_maxExtent; -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3D_QGEOMETRY_P_H - diff --git a/src/render/geometry/qgeometryfactory_p.h b/src/render/geometry/qgeometryfactory_p.h deleted file mode 100644 index ac7900dba..000000000 --- a/src/render/geometry/qgeometryfactory_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QGEOMETRYFACTORY -#define QT3DRENDER_QGEOMETRYFACTORY - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class QGeometry; - -class Q_3DRENDERSHARED_EXPORT QGeometryFactory : public QAbstractFunctor -{ -public: - virtual ~QGeometryFactory(); - virtual QGeometry *operator()() = 0; - virtual bool operator ==(const QGeometryFactory &other) const = 0; -}; - -typedef QSharedPointer QGeometryFactoryPtr; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(Qt3DRender::QGeometryFactoryPtr) // LCOV_EXCL_LINE - -#endif // QT3DRENDER_QGEOMETRYFACTORY - diff --git a/src/render/geometry/qgeometryrenderer.cpp b/src/render/geometry/qgeometryrenderer.cpp index 75e9b3a6a..11a5460d0 100644 --- a/src/render/geometry/qgeometryrenderer.cpp +++ b/src/render/geometry/qgeometryrenderer.cpp @@ -88,7 +88,7 @@ QGeometryRendererPrivate::~QGeometryRendererPrivate() \brief Encapsulates geometry rendering. A Qt3DRender::QGeometryRenderer holds all the information necessary to draw - a Qt3DRender::QGeometry. A QGeometry holds the coordinates of the geometry data - + a Qt3DCore::QGeometry. A QGeometry holds the coordinates of the geometry data - QGeometryRenderer specifies how to interpret that data. */ diff --git a/src/render/geometry/qgeometryrenderer.h b/src/render/geometry/qgeometryrenderer.h index 5a98329f6..435a315ad 100644 --- a/src/render/geometry/qgeometryrenderer.h +++ b/src/render/geometry/qgeometryrenderer.h @@ -41,11 +41,17 @@ #define QT3DRENDER_QGEOMETRYRENDERER_H #include -#include +#include #include QT_BEGIN_NAMESPACE +namespace Qt3DCore { +class QGeometryFactory; + +typedef QSharedPointer QGeometryFactoryPtr; +} + namespace Qt3DRender { class QGeometryRendererPrivate; @@ -62,7 +68,7 @@ class Q_3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QComponent Q_PROPERTY(int restartIndexValue READ restartIndexValue WRITE setRestartIndexValue NOTIFY restartIndexValueChanged) Q_PROPERTY(int verticesPerPatch READ verticesPerPatch WRITE setVerticesPerPatch NOTIFY verticesPerPatchChanged) Q_PROPERTY(bool primitiveRestartEnabled READ primitiveRestartEnabled WRITE setPrimitiveRestartEnabled NOTIFY primitiveRestartEnabledChanged) - Q_PROPERTY(Qt3DRender::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) + Q_PROPERTY(Qt3DCore::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged) public: @@ -97,7 +103,7 @@ public: int restartIndexValue() const; int verticesPerPatch() const; bool primitiveRestartEnabled() const; - QGeometry *geometry() const; + Qt3DCore::QGeometry *geometry() const; PrimitiveType primitiveType() const; public Q_SLOTS: @@ -110,7 +116,7 @@ public Q_SLOTS: void setRestartIndexValue(int index); void setVerticesPerPatch(int verticesPerPatch); void setPrimitiveRestartEnabled(bool enabled); - void setGeometry(QGeometry *geometry); + void setGeometry(Qt3DCore::QGeometry *geometry); void setPrimitiveType(PrimitiveType primitiveType); Q_SIGNALS: @@ -123,7 +129,7 @@ Q_SIGNALS: void restartIndexValueChanged(int restartIndexValue); void verticesPerPatchChanged(int verticesPerPatch); void primitiveRestartEnabledChanged(bool primitiveRestartEnabled); - void geometryChanged(QGeometry *geometry); + void geometryChanged(Qt3DCore::QGeometry *geometry); void primitiveTypeChanged(PrimitiveType primitiveType); protected: diff --git a/src/render/geometry/qgeometryrenderer_p.h b/src/render/geometry/qgeometryrenderer_p.h index 926eb24f7..ab2a3f0f8 100644 --- a/src/render/geometry/qgeometryrenderer_p.h +++ b/src/render/geometry/qgeometryrenderer_p.h @@ -51,9 +51,9 @@ // We mean it. // +#include #include #include -#include #include #include @@ -78,9 +78,9 @@ public: int m_restartIndexValue; int m_verticesPerPatch; bool m_primitiveRestart; - QGeometry *m_geometry; + Qt3DCore::QGeometry *m_geometry; QGeometryRenderer::PrimitiveType m_primitiveType; - QGeometryFactoryPtr m_geometryFactory; + Qt3DCore::QGeometryFactoryPtr m_geometryFactory; }; } // namespace Qt3DRender diff --git a/src/render/geometry/qmesh.cpp b/src/render/geometry/qmesh.cpp index 531312fb1..1180380b0 100644 --- a/src/render/geometry/qmesh.cpp +++ b/src/render/geometry/qmesh.cpp @@ -52,11 +52,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include @@ -64,6 +64,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt3DCore; + namespace Qt3DRender { Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, geometryLoader, (QGeometryLoaderFactory_iid, QLatin1String("/geometryloaders"), Qt::CaseInsensitive)) @@ -291,7 +293,7 @@ MeshLoaderFunctor::MeshLoaderFunctor(QMesh *mesh, const QByteArray &sourceData) /*! * \internal */ -QGeometry *MeshLoaderFunctor::operator()() +Qt3DCore::QGeometry *MeshLoaderFunctor::operator()() { m_status = QMesh::Loading; @@ -329,7 +331,7 @@ QGeometry *MeshLoaderFunctor::operator()() if (!ext.contains(QLatin1String("obj"))) ext << QLatin1String("obj"); } else { - QString filePath = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_sourcePath); + QString filePath = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(m_sourcePath); QFileInfo finfo(filePath); if (finfo.suffix().isEmpty()) ext << QLatin1String("obj"); @@ -350,7 +352,7 @@ QGeometry *MeshLoaderFunctor::operator()() } if (m_sourceData.isEmpty()) { - QString filePath = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_sourcePath); + QString filePath = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(m_sourcePath); QFile file(filePath); if (!file.open(QIODevice::ReadOnly)) { qCDebug(Render::Jobs) << "Could not open file" << filePath << "for reading"; @@ -359,7 +361,7 @@ QGeometry *MeshLoaderFunctor::operator()() } if (loader->load(&file, m_meshName)) { - Qt3DRender::QGeometry *geometry = loader->geometry(); + Qt3DCore::QGeometry *geometry = loader->geometry(); m_status = geometry != nullptr ? QMesh::Ready : QMesh::Error; return geometry; } @@ -372,7 +374,7 @@ QGeometry *MeshLoaderFunctor::operator()() } if (loader->load(&buffer, m_meshName)) { - Qt3DRender::QGeometry *geometry = loader->geometry(); + Qt3DCore::QGeometry *geometry = loader->geometry(); m_status = geometry != nullptr ? QMesh::Ready : QMesh::Error; return geometry; } @@ -423,7 +425,7 @@ void MeshDownloadRequest::onCompleted() return; QGeometryFactoryPtr geometryFactory = renderer->geometryFactory(); - if (!geometryFactory.isNull() && geometryFactory->id() == Qt3DRender::functorTypeId()) { + if (!geometryFactory.isNull() && geometryFactory->id() == Qt3DCore::functorTypeId()) { QSharedPointer functor = qSharedPointerCast(geometryFactory); // We make sure we are setting the result for the right request diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h index c80c930c5..9d34a6ae6 100644 --- a/src/render/geometry/qmesh_p.h +++ b/src/render/geometry/qmesh_p.h @@ -98,7 +98,7 @@ private: Render::NodeManagers *m_nodeManagers; }; -class Q_AUTOTEST_EXPORT MeshLoaderFunctor : public QGeometryFactory +class Q_AUTOTEST_EXPORT MeshLoaderFunctor : public Qt3DCore::QGeometryFactory { public : MeshLoaderFunctor(QMesh *mesh, const QByteArray &sourceData = QByteArray()); @@ -118,12 +118,9 @@ public : QMesh::Status status() const { return m_status; } - QGeometry *operator()() override; - bool operator ==(const QGeometryFactory &other) const override; - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED + Qt3DCore::QGeometry *operator()() override; + bool operator ==(const Qt3DCore::QGeometryFactory &other) const override; QT3D_FUNCTOR(MeshLoaderFunctor) - QT_WARNING_POP private: Qt3DCore::QNodeId m_mesh; diff --git a/src/render/io/io.pri b/src/render/io/io.pri index 6a48ebbc4..f01b11ce5 100644 --- a/src/render/io/io.pri +++ b/src/render/io/io.pri @@ -4,7 +4,6 @@ HEADERS += \ $$PWD/qaxisalignedboundingbox_p.h \ $$PWD/qsceneloader.h \ $$PWD/qsceneloader_p.h \ - $$PWD/qurlhelper_p.h \ $$PWD/scene_p.h \ $$PWD/scenemanager_p.h \ $$PWD/qsceneimporter_p.h \ @@ -19,7 +18,6 @@ HEADERS += \ SOURCES += \ $$PWD/qaxisalignedboundingbox.cpp \ $$PWD/qsceneloader.cpp \ - $$PWD/qurlhelper.cpp \ $$PWD/scene.cpp \ $$PWD/scenemanager.cpp \ $$PWD/qsceneimporter.cpp \ diff --git a/src/render/io/qgeometryloaderinterface_p.h b/src/render/io/qgeometryloaderinterface_p.h index 36928445f..f264cc6b2 100644 --- a/src/render/io/qgeometryloaderinterface_p.h +++ b/src/render/io/qgeometryloaderinterface_p.h @@ -59,14 +59,16 @@ QT_BEGIN_NAMESPACE class QIODevice; -namespace Qt3DRender { - +namespace Qt3DCore { class QGeometry; +} + +namespace Qt3DRender { class Q_3DRENDERSHARED_PRIVATE_EXPORT QGeometryLoaderInterface : public QObject { public: - virtual QGeometry *geometry() const = 0; + virtual Qt3DCore::QGeometry *geometry() const = 0; virtual bool load(QIODevice *ioDev, const QString &subMesh = QString()) = 0; }; diff --git a/src/render/io/qurlhelper.cpp b/src/render/io/qurlhelper.cpp deleted file mode 100644 index f55a547fb..000000000 --- a/src/render/io/qurlhelper.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qurlhelper_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -QString QUrlHelper::urlToLocalFileOrQrc(const QUrl &url) -{ - const QString scheme(url.scheme().toLower()); - if (scheme == QLatin1String("qrc")) { - if (url.authority().isEmpty()) - return QLatin1Char(':') + url.path(); - return QString(); - } - -#if defined(Q_OS_ANDROID) - if (scheme == QLatin1String("assets")) { - if (url.authority().isEmpty()) - return url.toString(); - return QString(); - } -#endif - - return url.toLocalFile(); -} - -} // Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/io/qurlhelper_p.h b/src/render/io/qurlhelper_p.h deleted file mode 100644 index d816d5d31..000000000 --- a/src/render/io/qurlhelper_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QURLHELPER_P_H -#define QT3DRENDER_QURLHELPER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { - -class Q_3DRENDERSHARED_EXPORT QUrlHelper -{ -public: - static QString urlToLocalFileOrQrc(const QUrl &url); -}; - -} // Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QURLHELPER_P_H diff --git a/src/render/jobs/calcboundingvolumejob.cpp b/src/render/jobs/calcboundingvolumejob.cpp index 1e4656247..1f0d9ccce 100644 --- a/src/render/jobs/calcboundingvolumejob.cpp +++ b/src/render/jobs/calcboundingvolumejob.cpp @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include @@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt3DCore; + namespace Qt3DRender { namespace Render { @@ -271,7 +273,7 @@ QVector calculateLocalBoundingVolume(NodeManagers *manager, Entity * for (Qt3DCore::QNodeId attrNodeId : attributes) { Qt3DRender::Render::Attribute *attr = manager->lookupResource(attrNodeId); - if (attr && attr->attributeType() == Qt3DRender::QAttribute::IndexAttribute) { + if (attr && attr->attributeType() == QAttribute::IndexAttribute) { indexBuf = manager->lookupResource(attr->bufferId()); if (indexBuf) { indexAttribute = attr; @@ -361,10 +363,10 @@ public: void postFrame(Qt3DCore::QAspectManager *manager) override { for (Geometry *backend : qAsConst(m_updatedGeometries)) { - QGeometry *node = qobject_cast(manager->lookupNode(backend->peerId())); + Qt3DCore::QGeometry *node = qobject_cast(manager->lookupNode(backend->peerId())); if (!node) continue; - QGeometryPrivate *dNode = static_cast(Qt3DCore::QNodePrivate::get(node)); + Qt3DCore::QGeometryPrivate *dNode = static_cast(Qt3DCore::QNodePrivate::get(node)); dNode->setExtent(backend->min(), backend->max()); } } diff --git a/src/render/jobs/loadbufferjob.cpp b/src/render/jobs/loadbufferjob.cpp index fd57248e1..f70426ac6 100644 --- a/src/render/jobs/loadbufferjob.cpp +++ b/src/render/jobs/loadbufferjob.cpp @@ -39,9 +39,9 @@ #include "loadbufferjob_p.h" #include -#include #include #include +#include #include #include @@ -90,8 +90,8 @@ void LoadBufferJobPrivate::postFrame(Qt3DCore::QAspectManager *aspectManager) { if (m_bufferToUpdate == nullptr) return; - QBuffer *frontendBuffer = static_cast(aspectManager->lookupNode(m_bufferToUpdate->peerId())); - QBufferPrivate *dFrontend = static_cast(Qt3DCore::QNodePrivate::get(frontendBuffer)); + Qt3DCore::QBuffer *frontendBuffer = static_cast(aspectManager->lookupNode(m_bufferToUpdate->peerId())); + Qt3DCore::QBufferPrivate *dFrontend = static_cast(Qt3DCore::QNodePrivate::get(frontendBuffer)); // Calling frontendBuffer->setData would result in forcing a sync against the backend // which isn't necessary dFrontend->setData(m_bufferToUpdate->data()); diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp index 959cbe3eb..f22f4a84c 100644 --- a/src/render/jobs/loadscenejob.cpp +++ b/src/render/jobs/loadscenejob.cpp @@ -43,9 +43,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -106,7 +106,7 @@ void LoadSceneJob::run() finalStatus = QSceneLoader::Error; if (m_data.isEmpty()) { - const QString path = QUrlHelper::urlToLocalFileOrQrc(m_source); + const QString path = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(m_source); const QFileInfo finfo(path); qCDebug(SceneLoaders) << Q_FUNC_INFO << "Attempting to load" << finfo.filePath(); if (finfo.exists()) { diff --git a/src/render/jobs/loadskeletonjob.cpp b/src/render/jobs/loadskeletonjob.cpp index de12b7e39..763c06530 100644 --- a/src/render/jobs/loadskeletonjob.cpp +++ b/src/render/jobs/loadskeletonjob.cpp @@ -42,10 +42,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -128,7 +128,7 @@ void LoadSkeletonJob::loadSkeletonFromUrl(Skeleton *skeleton) using namespace Qt3DCore; // TODO: Handle remote files - QString filePath = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(skeleton->source()); + QString filePath = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(skeleton->source()); QFileInfo info(filePath); if (!info.exists()) { qWarning() << "Could not open skeleton file:" << filePath; diff --git a/src/render/jobs/sendbuffercapturejob.cpp b/src/render/jobs/sendbuffercapturejob.cpp index 2ccb72337..b6a3cabcf 100644 --- a/src/render/jobs/sendbuffercapturejob.cpp +++ b/src/render/jobs/sendbuffercapturejob.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -112,10 +112,10 @@ void SendBufferCaptureJobPrivate::postFrame(Qt3DCore::QAspectManager *aspectMana QMutexLocker locker(&m_mutex); const QVector> pendingSendBufferCaptures = std::move(m_buffersToNotify); for (const auto &bufferDataPair : pendingSendBufferCaptures) { - QBuffer *frontendBuffer = static_cast(aspectManager->lookupNode(bufferDataPair.first)); + Qt3DCore::QBuffer *frontendBuffer = static_cast(aspectManager->lookupNode(bufferDataPair.first)); if (!frontendBuffer) continue; - QBufferPrivate *dFrontend = static_cast(Qt3DCore::QNodePrivate::get(frontendBuffer)); + Qt3DCore::QBufferPrivate *dFrontend = static_cast(Qt3DCore::QNodePrivate::get(frontendBuffer)); // Calling frontendBuffer->setData would result in forcing a sync against the backend // which isn't necessary dFrontend->setData(bufferDataPair.second); diff --git a/src/render/materialsystem/parameter.cpp b/src/render/materialsystem/parameter.cpp index 3360aebef..d515361ab 100644 --- a/src/render/materialsystem/parameter.cpp +++ b/src/render/materialsystem/parameter.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/src/render/materialsystem/qshaderprogram.cpp b/src/render/materialsystem/qshaderprogram.cpp index 8281d2707..50eb26a30 100644 --- a/src/render/materialsystem/qshaderprogram.cpp +++ b/src/render/materialsystem/qshaderprogram.cpp @@ -39,7 +39,7 @@ #include "qshaderprogram.h" #include "qshaderprogram_p.h" -#include +#include #include #include #include @@ -710,7 +710,7 @@ QByteArray QShaderProgramPrivate::deincludify(const QByteArray &contents, const QByteArray QShaderProgram::loadSource(const QUrl &sourceUrl) { // TO DO: Handle remote path - return QShaderProgramPrivate::deincludify(Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(sourceUrl)); + return QShaderProgramPrivate::deincludify(Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(sourceUrl)); } } // of namespace Qt3DRender diff --git a/src/render/materialsystem/qshaderprogrambuilder.cpp b/src/render/materialsystem/qshaderprogrambuilder.cpp index 60685d73c..a52e3ddaa 100644 --- a/src/render/materialsystem/qshaderprogrambuilder.cpp +++ b/src/render/materialsystem/qshaderprogrambuilder.cpp @@ -40,7 +40,6 @@ #include "qshaderprogrambuilder.h" #include "qshaderprogrambuilder_p.h" #include "qshaderprogram.h" -#include #include #include #include diff --git a/src/render/materialsystem/shaderbuilder.cpp b/src/render/materialsystem/shaderbuilder.cpp index 5c933759f..871b4cb4c 100644 --- a/src/render/materialsystem/shaderbuilder.cpp +++ b/src/render/materialsystem/shaderbuilder.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -213,7 +213,7 @@ bool ShaderBuilder::isShaderCodeDirty(QShaderProgram::ShaderType type) const void ShaderBuilder::generateCode(QShaderProgram::ShaderType type) { - const auto graphPath = QUrlHelper::urlToLocalFileOrQrc(shaderGraph(type)); + const auto graphPath = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(shaderGraph(type)); QFile file(graphPath); if (!file.open(QFile::ReadOnly)) { qWarning() << "Couldn't open file:" << graphPath; diff --git a/src/render/picking/objectpicker.cpp b/src/render/picking/objectpicker.cpp index 84169586e..7d6fcede8 100644 --- a/src/render/picking/objectpicker.cpp +++ b/src/render/picking/objectpicker.cpp @@ -41,7 +41,6 @@ #include "qpickevent.h" #include #include -#include #include QT_BEGIN_NAMESPACE diff --git a/src/render/picking/qobjectpicker.cpp b/src/render/picking/qobjectpicker.cpp index 15dc70536..498b0d97a 100644 --- a/src/render/picking/qobjectpicker.cpp +++ b/src/render/picking/qobjectpicker.cpp @@ -76,7 +76,7 @@ namespace Qt3DRender { For generalised ray casting queries, see Qt3DRender::QRayCaster and Qt3DRender::QScreenRayCaster. - \sa Qt3DRender::QPickingSettings, Qt3DRender::QGeometry, Qt3DRender::QAttribute, + \sa Qt3DRender::QPickingSettings, Qt3DCore::QGeometry, Qt3DCore::QAttribute, Qt3DRender::QPickEvent, Qt3DRender::QPickTriangleEvent, Qt3DRender::QNoPicking \note Instances of this component shouldn't be shared, not respecting that diff --git a/src/render/picking/qobjectpicker.h b/src/render/picking/qobjectpicker.h index 98516db76..c2c93272c 100644 --- a/src/render/picking/qobjectpicker.h +++ b/src/render/picking/qobjectpicker.h @@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QAttribute; class QObjectPickerPrivate; class QPickEvent; diff --git a/src/render/texture/qtexture.cpp b/src/render/texture/qtexture.cpp index 6b7b92166..f30e23d41 100644 --- a/src/render/texture/qtexture.cpp +++ b/src/render/texture/qtexture.cpp @@ -52,11 +52,11 @@ #include #include #include +#include #include #include #include #include -#include #include QT_BEGIN_NAMESPACE @@ -1001,7 +1001,7 @@ QTextureImageDataPtr TextureLoadingHelper::loadTextureData(const QUrl &url, bool || url.scheme() == QLatin1String("assets") #endif ) { - const QString source = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(url); + const QString source = Qt3DCore::QUrlHelper::urlToLocalFileOrQrc(url); QFile f(source); if (!f.open(QIODevice::ReadOnly)) qWarning() << "Failed to open" << source; diff --git a/src/render/texture/qtexturegenerator_p.h b/src/render/texture/qtexturegenerator_p.h index a3b12273b..933346f2e 100644 --- a/src/render/texture/qtexturegenerator_p.h +++ b/src/render/texture/qtexturegenerator_p.h @@ -51,7 +51,7 @@ #ifndef QT3DRENDER_QTEXTUREGENERATOR_P_H #define QT3DRENDER_QTEXTUREGENERATOR_P_H -#include +#include #include #include #include @@ -63,7 +63,7 @@ namespace Qt3DRender { class QTextureData; typedef QSharedPointer QTextureDataPtr; -class Q_3DRENDERSHARED_EXPORT QTextureGenerator : public QAbstractFunctor +class Q_3DRENDERSHARED_EXPORT QTextureGenerator : public Qt3DCore::QAbstractFunctor { public: virtual ~QTextureGenerator(); diff --git a/src/render/texture/qtextureimage_p.h b/src/render/texture/qtextureimage_p.h index 3cb704cf8..09f0fe865 100644 --- a/src/render/texture/qtextureimage_p.h +++ b/src/render/texture/qtextureimage_p.h @@ -55,7 +55,6 @@ #include #include -#include #include #include diff --git a/src/render/texture/qtextureimagedata.cpp b/src/render/texture/qtextureimagedata.cpp index 28d296feb..1750fcb13 100644 --- a/src/render/texture/qtextureimagedata.cpp +++ b/src/render/texture/qtextureimagedata.cpp @@ -38,9 +38,9 @@ ****************************************************************************/ #include "qtextureimagedata_p.h" -#include #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/render/texture/qtextureimagedatagenerator.h b/src/render/texture/qtextureimagedatagenerator.h index 9dc636ea1..7eaba598d 100644 --- a/src/render/texture/qtextureimagedatagenerator.h +++ b/src/render/texture/qtextureimagedatagenerator.h @@ -40,7 +40,8 @@ #ifndef QT3DRENDER_QTEXTUREIMAGEDATAGENERATOR_H #define QT3DRENDER_QTEXTUREIMAGEDATAGENERATOR_H -#include +#include +#include #include // TO DO TexImageDataPtr -> QImageDataPtr + d_ptr @@ -55,7 +56,7 @@ namespace Qt3DRender { class QTextureImageData; typedef QSharedPointer QTextureImageDataPtr; -class Q_3DRENDERSHARED_EXPORT QTextureImageDataGenerator : public QAbstractFunctor +class Q_3DRENDERSHARED_EXPORT QTextureImageDataGenerator : public Qt3DCore::QAbstractFunctor { public: virtual ~QTextureImageDataGenerator(); diff --git a/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp b/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp index 77ff01851..f41c8871b 100644 --- a/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp +++ b/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp @@ -35,11 +35,11 @@ class tst_QMorphingAnimation : public QObject { Q_OBJECT - bool verifyAttribute(Qt3DRender::QGeometry *geometry, QString name, - Qt3DRender::QAttribute *attribute) + bool verifyAttribute(Qt3DCore::QGeometry *geometry, QString name, + Qt3DCore::QAttribute *attribute) { - const QVector attributes = geometry->attributes(); - for (const Qt3DRender::QAttribute *attr : attributes) { + const QVector attributes = geometry->attributes(); + for (const Qt3DCore::QAttribute *attr : attributes) { if (attr->name() == name) { if (attr == attribute) return true; @@ -161,15 +161,15 @@ private Q_SLOTS: const QString baseName("position"); const QString targetName("positionTarget"); Qt3DAnimation::QMorphingAnimation morphingAnimation; - Qt3DRender::QAttribute *base = new Qt3DRender::QAttribute; + Qt3DCore::QAttribute *base = new Qt3DCore::QAttribute; - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry; + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry; Qt3DAnimation::QMorphTarget *mt1 = new Qt3DAnimation::QMorphTarget(&morphingAnimation); Qt3DAnimation::QMorphTarget *mt2 = new Qt3DAnimation::QMorphTarget(&morphingAnimation); Qt3DAnimation::QMorphTarget *mt3 = new Qt3DAnimation::QMorphTarget(&morphingAnimation); - Qt3DRender::QAttribute *a1 = new Qt3DRender::QAttribute(geometry); - Qt3DRender::QAttribute *a2 = new Qt3DRender::QAttribute(geometry); - Qt3DRender::QAttribute *a3 = new Qt3DRender::QAttribute(geometry); + Qt3DCore::QAttribute *a1 = new Qt3DCore::QAttribute(geometry); + Qt3DCore::QAttribute *a2 = new Qt3DCore::QAttribute(geometry); + Qt3DCore::QAttribute *a3 = new Qt3DCore::QAttribute(geometry); Qt3DRender::QGeometryRenderer gr; base->setName(baseName); diff --git a/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp b/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp index 2cba9ba2a..1511ea167 100644 --- a/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp +++ b/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp @@ -50,11 +50,11 @@ private Q_SLOTS: { // GIVEN Qt3DAnimation::QMorphTarget morphTarget; - Qt3DRender::QAttribute attribute1; - Qt3DRender::QAttribute attribute2; + Qt3DCore::QAttribute attribute1; + Qt3DCore::QAttribute attribute2; - attribute1.setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - attribute2.setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); + attribute1.setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + attribute2.setName(Qt3DCore::QAttribute::defaultNormalAttributeName()); { // WHEN @@ -63,7 +63,7 @@ private Q_SLOTS: // THEN QStringList names = morphTarget.attributeNames(); QCOMPARE(names.size(), 1); - QCOMPARE(names.at(0), Qt3DRender::QAttribute::defaultPositionAttributeName()); + QCOMPARE(names.at(0), Qt3DCore::QAttribute::defaultPositionAttributeName()); } { @@ -73,23 +73,23 @@ private Q_SLOTS: // THEN QStringList names = morphTarget.attributeNames(); QCOMPARE(names.size(), 2); - QCOMPARE(names.at(1), Qt3DRender::QAttribute::defaultNormalAttributeName()); + QCOMPARE(names.at(1), Qt3DCore::QAttribute::defaultNormalAttributeName()); } } void testFromGeometry() { // GIVEN - Qt3DRender::QGeometry geometry; - Qt3DRender::QAttribute *attribute1 = new Qt3DRender::QAttribute; - Qt3DRender::QAttribute *attribute2 = new Qt3DRender::QAttribute; - attribute1->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - attribute2->setName(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + Qt3DCore::QGeometry geometry; + Qt3DCore::QAttribute *attribute1 = new Qt3DCore::QAttribute; + Qt3DCore::QAttribute *attribute2 = new Qt3DCore::QAttribute; + attribute1->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + attribute2->setName(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); geometry.addAttribute(attribute1); geometry.addAttribute(attribute2); QStringList attributes; - attributes.push_back(Qt3DRender::QAttribute::defaultPositionAttributeName()); + attributes.push_back(Qt3DCore::QAttribute::defaultPositionAttributeName()); { // WHEN @@ -99,20 +99,20 @@ private Q_SLOTS: // THEN QStringList names = morphTarget->attributeNames(); QCOMPARE(names.size(), 1); - QCOMPARE(names.at(0), Qt3DRender::QAttribute::defaultPositionAttributeName()); + QCOMPARE(names.at(0), Qt3DCore::QAttribute::defaultPositionAttributeName()); } { // WHEN - attributes.push_back(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + attributes.push_back(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); QScopedPointer morphTarget( Qt3DAnimation::QMorphTarget::fromGeometry(&geometry, attributes)); // THEN QStringList names = morphTarget->attributeNames(); QCOMPARE(names.size(), 2); - QCOMPARE(names.at(0), Qt3DRender::QAttribute::defaultPositionAttributeName()); - QCOMPARE(names.at(1), Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + QCOMPARE(names.at(0), Qt3DCore::QAttribute::defaultPositionAttributeName()); + QCOMPARE(names.at(1), Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); } } diff --git a/tests/auto/extras/common/geometrytesthelper.h b/tests/auto/extras/common/geometrytesthelper.h index b825fa407..a80d652a8 100644 --- a/tests/auto/extras/common/geometrytesthelper.h +++ b/tests/auto/extras/common/geometrytesthelper.h @@ -29,12 +29,12 @@ #ifndef GEOMETRYTESTHELPER_H #define GEOMETRYTESTHELPER_H -#include -#include -#include +#include +#include +#include template -IndexType extractIndexData(Qt3DRender::QAttribute *attribute, int index) +IndexType extractIndexData(Qt3DCore::QAttribute *attribute, int index) { // Get the raw data const IndexType *typedData = reinterpret_cast(attribute->buffer()->data().constData()); @@ -45,7 +45,7 @@ IndexType extractIndexData(Qt3DRender::QAttribute *attribute, int index) } template -VertexType extractVertexData(Qt3DRender::QAttribute *attribute, IndexType index) +VertexType extractVertexData(Qt3DCore::QAttribute *attribute, IndexType index) { // Get the raw data const char *rawData = attribute->buffer()->data().constData(); @@ -55,10 +55,10 @@ VertexType extractVertexData(Qt3DRender::QAttribute *attribute, IndexType index) // Construct vertex from the typed data VertexType vertex; - const Qt3DRender::QAttribute::VertexBaseType type = attribute->vertexBaseType(); + const Qt3DCore::QAttribute::VertexBaseType type = attribute->vertexBaseType(); switch (type) { - case Qt3DRender::QAttribute::Float: { + case Qt3DCore::QAttribute::Float: { const float *typedVertexData = reinterpret_cast(vertexData); const int components = attribute->vertexSize(); for (int i = 0; i < components; ++i) diff --git a/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp b/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp index f20b1e870..2bfa89601 100644 --- a/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp +++ b/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp @@ -29,9 +29,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -58,13 +58,13 @@ private Q_SLOTS: QCOMPARE(geometry.yzMeshResolution(), QSize(2, 2)); QCOMPARE(geometry.xzMeshResolution(), QSize(2, 2)); QVERIFY(geometry.positionAttribute() != nullptr); - QCOMPARE(geometry.positionAttribute()->name(), Qt3DRender::QAttribute::defaultPositionAttributeName()); + QCOMPARE(geometry.positionAttribute()->name(), Qt3DCore::QAttribute::defaultPositionAttributeName()); QVERIFY(geometry.normalAttribute() != nullptr); - QCOMPARE(geometry.normalAttribute()->name(), Qt3DRender::QAttribute::defaultNormalAttributeName()); + QCOMPARE(geometry.normalAttribute()->name(), Qt3DCore::QAttribute::defaultNormalAttributeName()); QVERIFY(geometry.texCoordAttribute() != nullptr); - QCOMPARE(geometry.texCoordAttribute()->name(), Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + QCOMPARE(geometry.texCoordAttribute()->name(), Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); QVERIFY(geometry.tangentAttribute() != nullptr); - QCOMPARE(geometry.tangentAttribute()->name(), Qt3DRender::QAttribute::defaultTangentAttributeName()); + QCOMPARE(geometry.tangentAttribute()->name(), Qt3DCore::QAttribute::defaultTangentAttributeName()); QVERIFY(geometry.indexAttribute() != nullptr); } @@ -520,12 +520,12 @@ private Q_SLOTS: { // GIVEN Qt3DExtras::QCuboidGeometry geometry; - const QVector attributes = geometry.attributes(); - Qt3DRender::QAttribute *positionAttribute = geometry.positionAttribute(); - Qt3DRender::QAttribute *normalAttribute = geometry.normalAttribute(); - Qt3DRender::QAttribute *texCoordAttribute = geometry.texCoordAttribute(); - Qt3DRender::QAttribute *tangentAttribute = geometry.tangentAttribute(); - Qt3DRender::QAttribute *indexAttribute = geometry.indexAttribute(); + const QVector attributes = geometry.attributes(); + Qt3DCore::QAttribute *positionAttribute = geometry.positionAttribute(); + Qt3DCore::QAttribute *normalAttribute = geometry.normalAttribute(); + Qt3DCore::QAttribute *texCoordAttribute = geometry.texCoordAttribute(); + Qt3DCore::QAttribute *tangentAttribute = geometry.tangentAttribute(); + Qt3DCore::QAttribute *indexAttribute = geometry.indexAttribute(); // WHEN QFETCH(float, xExtent); @@ -545,7 +545,7 @@ private Q_SLOTS: // Check buffer of each attribute is valid and actually has some data for (const auto &attribute : attributes) { - Qt3DRender::QBuffer *buffer = attribute->buffer(); + Qt3DCore::QBuffer *buffer = attribute->buffer(); QVERIFY(buffer != nullptr); QVERIFY(buffer->data().size() != 0); } diff --git a/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp b/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp index 7a6965f20..08afd09e3 100644 --- a/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp +++ b/tests/auto/extras/qtorusgeometry/tst_qtorusgeometry.cpp @@ -29,9 +29,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -57,14 +57,14 @@ private Q_SLOTS: QCOMPARE(geometry.radius(), 1.0f); QCOMPARE(geometry.minorRadius(), 1.0f); QVERIFY(geometry.positionAttribute() != nullptr); - QCOMPARE(geometry.positionAttribute()->name(), Qt3DRender::QAttribute::defaultPositionAttributeName()); + QCOMPARE(geometry.positionAttribute()->name(), Qt3DCore::QAttribute::defaultPositionAttributeName()); QVERIFY(geometry.normalAttribute() != nullptr); - QCOMPARE(geometry.normalAttribute()->name(), Qt3DRender::QAttribute::defaultNormalAttributeName()); + QCOMPARE(geometry.normalAttribute()->name(), Qt3DCore::QAttribute::defaultNormalAttributeName()); QVERIFY(geometry.texCoordAttribute() != nullptr); - QCOMPARE(geometry.texCoordAttribute()->name(), Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + QCOMPARE(geometry.texCoordAttribute()->name(), Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); // TODO: Expose tangent attribute in Qt 5.8 and see below // QVERIFY(geometry.tangentAttribute() != nullptr); -// QCOMPARE(geometry.tangentAttribute()->name(), Qt3DRender::QAttribute::defaultTangentAttributeName()); +// QCOMPARE(geometry.tangentAttribute()->name(), Qt3DCore::QAttribute::defaultTangentAttributeName()); QVERIFY(geometry.indexAttribute() != nullptr); } @@ -299,12 +299,12 @@ private Q_SLOTS: { // GIVEN Qt3DExtras::QTorusGeometry geometry; - const QVector attributes = geometry.attributes(); - Qt3DRender::QAttribute *positionAttribute = geometry.positionAttribute(); - Qt3DRender::QAttribute *normalAttribute = geometry.normalAttribute(); - Qt3DRender::QAttribute *texCoordAttribute = geometry.texCoordAttribute(); -// Qt3DRender::QAttribute *tangentAttribute = geometry.tangentAttribute(); - Qt3DRender::QAttribute *indexAttribute = geometry.indexAttribute(); + const QVector attributes = geometry.attributes(); + Qt3DCore::QAttribute *positionAttribute = geometry.positionAttribute(); + Qt3DCore::QAttribute *normalAttribute = geometry.normalAttribute(); + Qt3DCore::QAttribute *texCoordAttribute = geometry.texCoordAttribute(); +// Qt3DCore::QAttribute *tangentAttribute = geometry.tangentAttribute(); + Qt3DCore::QAttribute *indexAttribute = geometry.indexAttribute(); // WHEN QFETCH(int, rings); @@ -320,7 +320,7 @@ private Q_SLOTS: // Check buffer of each attribute is valid and actually has some data for (const auto &attribute : attributes) { - Qt3DRender::QBuffer *buffer = attribute->buffer(); + Qt3DCore::QBuffer *buffer = attribute->buffer(); QVERIFY(buffer != nullptr); QVERIFY(buffer->data().size() != 0); } diff --git a/tests/auto/quick3d/3dcore/3dcore.qml b/tests/auto/quick3d/3dcore/3dcore.qml index d0a5c6f09..664c29bc9 100644 --- a/tests/auto/quick3d/3dcore/3dcore.qml +++ b/tests/auto/quick3d/3dcore/3dcore.qml @@ -50,4 +50,8 @@ Item { QQ3Core210.Joint {} QQ3Core214.Transform {} + + QQ3Core20.Attribute {} //Qt3DCore::QAttribute + QQ3Core20.Buffer {} //Qt3DCore::Quick::Quick3DBuffer + QQ3Core20.Geometry {} //Qt3DCore::QGeometry, Qt3DCore::Quick::Quick3DGeometry } diff --git a/tests/auto/quick3d/3drender/3drender.qml b/tests/auto/quick3d/3drender/3drender.qml index 8c200f3c0..cc0db1ab1 100644 --- a/tests/auto/quick3d/3drender/3drender.qml +++ b/tests/auto/quick3d/3drender/3drender.qml @@ -87,10 +87,6 @@ Item { QQ3Render213.SetFence {} //Qt3DRender::QSetFence // Geometry - QQ3Render20.Attribute {} //Qt3DRender::QAttribute - //QQ3Render20.BufferBase // (uncreatable) Qt3DRender::QBuffer - QQ3Render20.Buffer {} //Qt3DRender::Render::Quick::Quick3DBuffer - QQ3Render20.Geometry {} //Qt3DRender::QGeometry, Qt3DRender::Render::Quick::Quick3DGeometry QQ3Render20.GeometryRenderer {} //Qt3DRender::QGeometryRenderer // Mesh diff --git a/tests/auto/quick3d/quick3dbuffer/quick3dbuffer.pro b/tests/auto/quick3d/quick3dbuffer/quick3dbuffer.pro index f36e42ff5..afcc30d19 100644 --- a/tests/auto/quick3d/quick3dbuffer/quick3dbuffer.pro +++ b/tests/auto/quick3d/quick3dbuffer/quick3dbuffer.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = tst_quick3dbuffer -QT += 3dcore 3dcore-private 3drender 3drender-private 3dquick 3dquick-private 3dquickrender-private testlib +QT += 3dcore 3dcore-private 3dquick 3dquick-private testlib CONFIG += testcase diff --git a/tests/auto/quick3d/quick3dbuffer/tst_quick3dbuffer.cpp b/tests/auto/quick3d/quick3dbuffer/tst_quick3dbuffer.cpp index 0392c0402..21f62ac00 100644 --- a/tests/auto/quick3d/quick3dbuffer/tst_quick3dbuffer.cpp +++ b/tests/auto/quick3d/quick3dbuffer/tst_quick3dbuffer.cpp @@ -28,7 +28,7 @@ #include -#include +#include #include #include @@ -53,7 +53,7 @@ private Q_SLOTS: void checkInvalidBinaryFile() { // GIVEN - Qt3DRender::Render::Quick::Quick3DBuffer buf; + Qt3DCore::Quick::Quick3DBuffer buf; // WHEN QVariant data = buf.readBinaryFile(QUrl::fromLocalFile(QLatin1String("this_should_not_exist.bin"))); @@ -66,7 +66,7 @@ private Q_SLOTS: void checkValidBinaryFile() { // GIVEN - Qt3DRender::Render::Quick::Quick3DBuffer buf; + Qt3DCore::Quick::Quick3DBuffer buf; QVector dataArray = QVector() << QVector3D(327.0f, 350.0f, 355.0f) << QVector3D(383.0f, 427.0f, 454.0f); diff --git a/tests/auto/render/attribute/tst_attribute.cpp b/tests/auto/render/attribute/tst_attribute.cpp index 5571ef334..0b47f808d 100644 --- a/tests/auto/render/attribute/tst_attribute.cpp +++ b/tests/auto/render/attribute/tst_attribute.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "testrenderer.h" class tst_Attribute : public Qt3DCore::QBackendNodeTester @@ -45,18 +45,18 @@ private Q_SLOTS: Qt3DRender::Render::Attribute renderAttribute; renderAttribute.setRenderer(&renderer); - Qt3DRender::QAttribute attribute; - attribute.setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + Qt3DCore::QAttribute attribute; + attribute.setAttributeType(Qt3DCore::QAttribute::IndexAttribute); attribute.setByteOffset(1200); attribute.setByteStride(883); attribute.setCount(427); attribute.setDivisor(305); attribute.setName(QStringLiteral("C3")); - attribute.setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + attribute.setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); attribute.setVertexSize(3); - Qt3DRender::QBuffer buffer; - buffer.setUsage(Qt3DRender::QBuffer::DynamicCopy); + Qt3DCore::QBuffer buffer; + buffer.setUsage(Qt3DCore::QBuffer::DynamicCopy); buffer.setData(QByteArrayLiteral("Corvette")); attribute.setBuffer(&buffer); @@ -89,26 +89,26 @@ private Q_SLOTS: QVERIFY(renderAttribute.bufferId().isNull()); QVERIFY(renderAttribute.name().isEmpty()); QCOMPARE(renderAttribute.isDirty(), false); - QCOMPARE(renderAttribute.vertexBaseType(), Qt3DRender::QAttribute::Float); + QCOMPARE(renderAttribute.vertexBaseType(), Qt3DCore::QAttribute::Float); QCOMPARE(renderAttribute.vertexSize(), 1U); - QCOMPARE(renderAttribute.attributeType(), Qt3DRender::QAttribute::VertexAttribute); + QCOMPARE(renderAttribute.attributeType(), Qt3DCore::QAttribute::VertexAttribute); QCOMPARE(renderAttribute.byteOffset(), 0U); QCOMPARE(renderAttribute.byteStride(), 0U); QCOMPARE(renderAttribute.count(), 0U); QCOMPARE(renderAttribute.divisor(), 0U); // GIVEN - Qt3DRender::QAttribute attribute; - attribute.setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + Qt3DCore::QAttribute attribute; + attribute.setAttributeType(Qt3DCore::QAttribute::IndexAttribute); attribute.setByteOffset(1200); attribute.setByteStride(883); attribute.setCount(427); attribute.setDivisor(305); attribute.setName(QStringLiteral("C3")); - attribute.setVertexBaseType(Qt3DRender::QAttribute::Double); + attribute.setVertexBaseType(Qt3DCore::QAttribute::Double); attribute.setVertexSize(4); - Qt3DRender::QBuffer buffer; - buffer.setUsage(Qt3DRender::QBuffer::DynamicCopy); + Qt3DCore::QBuffer buffer; + buffer.setUsage(Qt3DCore::QBuffer::DynamicCopy); buffer.setData(QByteArrayLiteral("C7")); attribute.setBuffer(&buffer); @@ -120,9 +120,9 @@ private Q_SLOTS: QVERIFY(renderAttribute.bufferId().isNull()); QVERIFY(renderAttribute.name().isEmpty()); QCOMPARE(renderAttribute.isDirty(), false); - QCOMPARE(renderAttribute.vertexBaseType(), Qt3DRender::QAttribute::Float); + QCOMPARE(renderAttribute.vertexBaseType(), Qt3DCore::QAttribute::Float); QCOMPARE(renderAttribute.vertexSize(), 1U); - QCOMPARE(renderAttribute.attributeType(), Qt3DRender::QAttribute::VertexAttribute); + QCOMPARE(renderAttribute.attributeType(), Qt3DCore::QAttribute::VertexAttribute); QCOMPARE(renderAttribute.byteOffset(), 0U); QCOMPARE(renderAttribute.byteStride(), 0U); QCOMPARE(renderAttribute.count(), 0U); @@ -132,7 +132,7 @@ private Q_SLOTS: void checkPropertyChanges() { // GIVEN - Qt3DRender::QAttribute attribute; + Qt3DCore::QAttribute attribute; TestRenderer renderer; Qt3DRender::Render::Attribute renderAttribute; renderAttribute.setRenderer(&renderer); @@ -144,11 +144,11 @@ private Q_SLOTS: QVERIFY(!renderer.dirtyBits()); // WHEN - attribute.setVertexBaseType(Qt3DRender::QAttribute::Int); + attribute.setVertexBaseType(Qt3DCore::QAttribute::Int); renderAttribute.syncFromFrontEnd(&attribute, false); // THEN - QCOMPARE(renderAttribute.vertexBaseType(), Qt3DRender::QAttribute::Int); + QCOMPARE(renderAttribute.vertexBaseType(), Qt3DCore::QAttribute::Int); QVERIFY(renderAttribute.isDirty()); QVERIFY(renderer.dirtyBits() != 0); @@ -171,11 +171,11 @@ private Q_SLOTS: QVERIFY(!renderAttribute.isDirty()); // WHEN - attribute.setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + attribute.setAttributeType(Qt3DCore::QAttribute::IndexAttribute); renderAttribute.syncFromFrontEnd(&attribute, false); // THEN - QCOMPARE(renderAttribute.attributeType(), Qt3DRender::QAttribute::IndexAttribute); + QCOMPARE(renderAttribute.attributeType(), Qt3DCore::QAttribute::IndexAttribute); QVERIFY(renderAttribute.isDirty()); QVERIFY(renderer.dirtyBits() != 0); @@ -184,11 +184,11 @@ private Q_SLOTS: QVERIFY(!renderAttribute.isDirty()); // WHEN - attribute.setAttributeType(Qt3DRender::QAttribute::DrawIndirectAttribute); + attribute.setAttributeType(Qt3DCore::QAttribute::DrawIndirectAttribute); renderAttribute.syncFromFrontEnd(&attribute, false); // THEN - QCOMPARE(renderAttribute.attributeType(), Qt3DRender::QAttribute::DrawIndirectAttribute); + QCOMPARE(renderAttribute.attributeType(), Qt3DCore::QAttribute::DrawIndirectAttribute); QVERIFY(renderAttribute.isDirty()); QVERIFY(renderer.dirtyBits() != 0); @@ -262,7 +262,7 @@ private Q_SLOTS: QVERIFY(!renderAttribute.isDirty()); // WHEN - auto buffer = new Qt3DRender::QBuffer(); + auto buffer = new Qt3DCore::QBuffer(); attribute.setBuffer(buffer); renderAttribute.syncFromFrontEnd(&attribute, false); diff --git a/tests/auto/render/boundingsphere/tst_boundingsphere.cpp b/tests/auto/render/boundingsphere/tst_boundingsphere.cpp index 6c5473cff..c929c5cb5 100644 --- a/tests/auto/render/boundingsphere/tst_boundingsphere.cpp +++ b/tests/auto/render/boundingsphere/tst_boundingsphere.cpp @@ -422,8 +422,8 @@ private Q_SLOTS: QScopedPointer entity(new Qt3DCore::QEntity); QScopedPointer test(new Qt3DRender::TestAspect(entity.data())); - Qt3DRender::QBuffer *vbuffer = new Qt3DRender::QBuffer; - Qt3DRender::QBuffer *ibuffer = new Qt3DRender::QBuffer; + Qt3DCore::QBuffer *vbuffer = new Qt3DCore::QBuffer; + Qt3DCore::QBuffer *ibuffer = new Qt3DCore::QBuffer; vbuffer->setData(vdata); Qt3DRender::Render::Buffer *vbufferBackend = test->nodeManagers()->bufferManager()->getOrCreateResource(vbuffer->id()); @@ -437,15 +437,15 @@ private Q_SLOTS: ibufferBackend->setManager(test->nodeManagers()->bufferManager()); simulateInitializationSync(ibuffer, ibufferBackend); - Qt3DRender::QGeometry *g = new Qt3DRender::QGeometry; + Qt3DCore::QGeometry *g = new Qt3DCore::QGeometry; for (int i = 0; i < 2; ++i) - g->addAttribute(new Qt3DRender::QAttribute); + g->addAttribute(new Qt3DCore::QAttribute); - const QVector attrs = g->attributes(); - Qt3DRender::QAttribute *attr = attrs[0]; + const QVector attrs = g->attributes(); + Qt3DCore::QAttribute *attr = attrs[0]; attr->setBuffer(vbuffer); - attr->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - attr->setVertexBaseType(Qt3DRender::QAttribute::Float); + attr->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + attr->setVertexBaseType(Qt3DCore::QAttribute::Float); attr->setVertexSize(3); attr->setCount(6); attr->setByteOffset(0); @@ -453,8 +453,8 @@ private Q_SLOTS: attr = attrs[1]; attr->setBuffer(ibuffer); - attr->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); - attr->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + attr->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); + attr->setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); attr->setVertexSize(1); attr->setCount(indexCount); attr->setByteOffset(indexByteOffset); @@ -534,7 +534,7 @@ private Q_SLOTS: QScopedPointer entity(new Qt3DCore::QEntity); QScopedPointer test(new Qt3DRender::TestAspect(entity.data())); - Qt3DRender::QBuffer *vbuffer = new Qt3DRender::QBuffer; + Qt3DCore::QBuffer *vbuffer = new Qt3DCore::QBuffer; vbuffer->setData(vdata); Qt3DRender::Render::Buffer *vbufferBackend = test->nodeManagers()->bufferManager()->getOrCreateResource(vbuffer->id()); @@ -542,14 +542,14 @@ private Q_SLOTS: vbufferBackend->setManager(test->nodeManagers()->bufferManager()); simulateInitializationSync(vbuffer, vbufferBackend); - Qt3DRender::QGeometry *g = new Qt3DRender::QGeometry; - g->addAttribute(new Qt3DRender::QAttribute); + Qt3DCore::QGeometry *g = new Qt3DCore::QGeometry; + g->addAttribute(new Qt3DCore::QAttribute); - const QVector attrs = g->attributes(); - Qt3DRender::QAttribute *attr = attrs[0]; + const QVector attrs = g->attributes(); + Qt3DCore::QAttribute *attr = attrs[0]; attr->setBuffer(vbuffer); - attr->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - attr->setVertexBaseType(Qt3DRender::QAttribute::Float); + attr->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + attr->setVertexBaseType(Qt3DCore::QAttribute::Float); attr->setVertexSize(3); attr->setCount(6); attr->setByteOffset(0); diff --git a/tests/auto/render/buffer/tst_buffer.cpp b/tests/auto/render/buffer/tst_buffer.cpp index b9284623d..1746b81f8 100644 --- a/tests/auto/render/buffer/tst_buffer.cpp +++ b/tests/auto/render/buffer/tst_buffer.cpp @@ -26,14 +26,10 @@ ** ****************************************************************************/ -// TODO Remove in Qt6 -#include -QT_WARNING_DISABLE_DEPRECATED - #include #include #include -#include +#include #include #include #include "testarbiter.h" @@ -49,11 +45,11 @@ private Q_SLOTS: { // GIVEN Qt3DRender::Render::Buffer renderBuffer; - Qt3DRender::QBuffer buffer; + Qt3DCore::QBuffer buffer; Qt3DRender::Render::BufferManager bufferManager; TestRenderer renderer; - buffer.setUsage(Qt3DRender::QBuffer::DynamicCopy); + buffer.setUsage(Qt3DCore::QBuffer::DynamicCopy); buffer.setData(QByteArrayLiteral("Corvette")); // WHEN @@ -79,13 +75,13 @@ private Q_SLOTS: // THEN QCOMPARE(backendBuffer.isDirty(), false); - QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::StaticDraw); + QCOMPARE(backendBuffer.usage(), Qt3DCore::QBuffer::StaticDraw); QVERIFY(backendBuffer.data().isEmpty()); QVERIFY(backendBuffer.peerId().isNull()); QVERIFY(backendBuffer.pendingBufferUpdates().empty()); // GIVEN - Qt3DRender::QBuffer frontendBuffer; + Qt3DCore::QBuffer frontendBuffer; // WHEN backendBuffer.setManager(&bufferManager); @@ -94,17 +90,17 @@ private Q_SLOTS: // THEN QCOMPARE(backendBuffer.isDirty(), true); - QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::StaticDraw); + QCOMPARE(backendBuffer.usage(), Qt3DCore::QBuffer::StaticDraw); QVERIFY(backendBuffer.data().isEmpty()); QVERIFY(backendBuffer.pendingBufferUpdates().empty()); // WHEN - frontendBuffer.setUsage(Qt3DRender::QBuffer::DynamicCopy); + frontendBuffer.setUsage(Qt3DCore::QBuffer::DynamicCopy); frontendBuffer.setData(QByteArrayLiteral("C7KR4")); backendBuffer.syncFromFrontEnd(&frontendBuffer, false); // THEN - QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::DynamicCopy); + QCOMPARE(backendBuffer.usage(), Qt3DCore::QBuffer::DynamicCopy); QCOMPARE(backendBuffer.isDirty(), true); QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7KR4")); QVERIFY(!backendBuffer.pendingBufferUpdates().empty()); @@ -121,7 +117,7 @@ private Q_SLOTS: // THEN QCOMPARE(backendBuffer.isDirty(), false); - QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::StaticDraw); + QCOMPARE(backendBuffer.usage(), Qt3DCore::QBuffer::StaticDraw); QVERIFY(backendBuffer.data().isEmpty()); QVERIFY(backendBuffer.pendingBufferUpdates().empty()); } @@ -133,7 +129,7 @@ private Q_SLOTS: Qt3DRender::Render::Buffer backendBuffer; Qt3DRender::Render::BufferManager bufferManager; TestRenderer renderer; - Qt3DRender::QBuffer frontendBuffer; + Qt3DCore::QBuffer frontendBuffer; QByteArray data("111456789\0"); @@ -150,7 +146,7 @@ private Q_SLOTS: // THEN QCOMPARE(backendBuffer.pendingBufferUpdates().size(), 1); - Qt3DRender::QBufferUpdate fullUpdate = backendBuffer.pendingBufferUpdates().first(); + Qt3DCore::QBufferUpdate fullUpdate = backendBuffer.pendingBufferUpdates().first(); QCOMPARE(fullUpdate.offset, -1); QVERIFY(fullUpdate.data.isEmpty()); QCOMPARE(frontendBuffer.data(), backendBuffer.data()); @@ -185,24 +181,24 @@ private Q_SLOTS: { // GIVEN TestRenderer renderer; - Qt3DRender::QBuffer frontendBuffer; + Qt3DCore::QBuffer frontendBuffer; Qt3DRender::Render::Buffer backendBuffer; backendBuffer.setRenderer(&renderer); simulateInitializationSync(&frontendBuffer, &backendBuffer); // THEN QVERIFY(backendBuffer.data().isEmpty()); - QVERIFY(backendBuffer.usage() != Qt3DRender::QBuffer::DynamicRead); + QVERIFY(backendBuffer.usage() != Qt3DCore::QBuffer::DynamicRead); QVERIFY(!backendBuffer.isDirty()); QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::BuffersDirty); renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); // WHEN - frontendBuffer.setUsage(Qt3DRender::QBuffer::DynamicRead); + frontendBuffer.setUsage(Qt3DCore::QBuffer::DynamicRead); backendBuffer.syncFromFrontEnd(&frontendBuffer, false); // THEN - QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::DynamicRead); + QCOMPARE(backendBuffer.usage(), Qt3DCore::QBuffer::DynamicRead); QVERIFY(backendBuffer.isDirty()); QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::BuffersDirty); @@ -252,7 +248,7 @@ private Q_SLOTS: { // GIVEN Qt3DRender::Render::Buffer renderBuffer; - Qt3DRender::QBuffer buffer; + Qt3DCore::QBuffer buffer; Qt3DRender::Render::BufferManager bufferManager; TestRenderer renderer; @@ -278,7 +274,7 @@ private Q_SLOTS: { // GIVEN Qt3DRender::Render::Buffer renderBuffer; - Qt3DRender::QBuffer buffer; + Qt3DCore::QBuffer buffer; Qt3DRender::Render::BufferManager bufferManager; TestRenderer renderer; diff --git a/tests/auto/render/coordinatereader/tst_coordinatereader.cpp b/tests/auto/render/coordinatereader/tst_coordinatereader.cpp index 417684245..9ff37f878 100644 --- a/tests/auto/render/coordinatereader/tst_coordinatereader.cpp +++ b/tests/auto/render/coordinatereader/tst_coordinatereader.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -115,11 +115,11 @@ private Q_SLOTS: void checkSetGeometry() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer( new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestReader reader(nodeManagers.data()); TestRenderer renderer; @@ -152,13 +152,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3 * 4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -182,13 +182,13 @@ private Q_SLOTS: // WHEN bool ret = reader.setGeometry(backendRenderer, - Qt3DRender::QAttribute::defaultPositionAttributeName()); + Qt3DCore::QAttribute::defaultPositionAttributeName()); // THEN QCOMPARE(ret, true); QCOMPARE(reader.attribute(), backendAttribute); QCOMPARE(reader.buffer(), backendBuffer); - QCOMPARE(reader.bufferInfo().type, Qt3DRender::QAttribute::Float); + QCOMPARE(reader.bufferInfo().type, Qt3DCore::QAttribute::Float); QCOMPARE(reader.bufferInfo().dataSize, 3u); QCOMPARE(reader.bufferInfo().count, 6u); QCOMPARE(reader.bufferInfo().byteStride, 12u); @@ -198,11 +198,11 @@ private Q_SLOTS: void testReadCoordinate() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer( new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestReader reader(nodeManagers.data()); TestRenderer renderer; @@ -235,13 +235,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3 * 4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -265,7 +265,7 @@ private Q_SLOTS: // WHEN bool ret = reader.setGeometry(backendRenderer, - Qt3DRender::QAttribute::defaultPositionAttributeName()); + Qt3DCore::QAttribute::defaultPositionAttributeName()); // THEN QCOMPARE(ret, true); @@ -281,11 +281,11 @@ private Q_SLOTS: void testReadCoordinateVec4() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer( new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestReader reader(nodeManagers.data()); TestRenderer renderer; @@ -329,13 +329,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(4); positionAttribute->setCount(6); positionAttribute->setByteStride(4 * 4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -359,7 +359,7 @@ private Q_SLOTS: // WHEN bool ret = reader.setGeometry(backendRenderer, - Qt3DRender::QAttribute::defaultPositionAttributeName()); + Qt3DCore::QAttribute::defaultPositionAttributeName()); // THEN QCOMPARE(ret, true); @@ -375,12 +375,12 @@ private Q_SLOTS: void testReadCoordinateFromAttribute() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer( new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer texcoordAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer texcoordAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestReader reader(nodeManagers.data()); TestRenderer renderer; @@ -418,23 +418,23 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(3); positionAttribute->setByteStride(3 * 4 * 2); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); texcoordAttribute->setBuffer(dataBuffer.data()); - texcoordAttribute->setName(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); - texcoordAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + texcoordAttribute->setName(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); + texcoordAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); texcoordAttribute->setVertexSize(3); texcoordAttribute->setCount(6); texcoordAttribute->setByteStride(3 * 4 * 2); texcoordAttribute->setByteOffset(3 * 4); - texcoordAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + texcoordAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(texcoordAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -463,7 +463,7 @@ private Q_SLOTS: // WHEN bool ret = reader.setGeometry(backendRenderer, - Qt3DRender::QAttribute::defaultPositionAttributeName()); + Qt3DCore::QAttribute::defaultPositionAttributeName()); // THEN QCOMPARE(ret, true); @@ -474,7 +474,7 @@ private Q_SLOTS: // WHEN ret = reader.setGeometry(backendRenderer, - Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); // THEN QCOMPARE(ret, true); diff --git a/tests/auto/render/geometry/tst_geometry.cpp b/tests/auto/render/geometry/tst_geometry.cpp index 9355f8339..aa856da39 100644 --- a/tests/auto/render/geometry/tst_geometry.cpp +++ b/tests/auto/render/geometry/tst_geometry.cpp @@ -33,18 +33,18 @@ QT_WARNING_DISABLE_DEPRECATED #include #include #include -#include -#include +#include +#include #include #include "testrenderer.h" #include "testarbiter.h" -class DummyAttribute : public Qt3DRender::QAttribute +class DummyAttribute : public Qt3DCore::QAttribute { Q_OBJECT public: DummyAttribute(Qt3DCore::QNode *parent = nullptr) - : Qt3DRender::QAttribute(parent) + : Qt3DCore::QAttribute(parent) {} }; @@ -60,11 +60,11 @@ private Q_SLOTS: Qt3DRender::Render::Geometry renderGeometry; TestRenderer renderer; - Qt3DRender::QGeometry geometry; - Qt3DRender::QAttribute attr1; - Qt3DRender::QAttribute attr2; - Qt3DRender::QAttribute attr4; - Qt3DRender::QAttribute attr3; + Qt3DCore::QGeometry geometry; + Qt3DCore::QAttribute attr1; + Qt3DCore::QAttribute attr2; + Qt3DCore::QAttribute attr4; + Qt3DCore::QAttribute attr3; geometry.addAttribute(&attr1); geometry.addAttribute(&attr2); @@ -91,7 +91,7 @@ private Q_SLOTS: { // GIVEN Qt3DRender::Render::Geometry renderGeometry; - Qt3DRender::QGeometry geometry; + Qt3DCore::QGeometry geometry; TestRenderer renderer; renderGeometry.setRenderer(&renderer); @@ -120,11 +120,11 @@ private Q_SLOTS: QCOMPARE(renderGeometry.boundingPositionAttribute(), Qt3DCore::QNodeId()); // GIVEN - Qt3DRender::QGeometry geometry; - Qt3DRender::QAttribute attr1; - Qt3DRender::QAttribute attr2; - Qt3DRender::QAttribute attr4; - Qt3DRender::QAttribute attr3; + Qt3DCore::QGeometry geometry; + Qt3DCore::QAttribute attr1; + Qt3DCore::QAttribute attr2; + Qt3DCore::QAttribute attr4; + Qt3DCore::QAttribute attr3; geometry.setBoundingVolumePositionAttribute(&attr1); geometry.addAttribute(&attr1); @@ -148,7 +148,7 @@ private Q_SLOTS: TestRenderer renderer; Qt3DRender::Render::Geometry renderGeometry; renderGeometry.setRenderer(&renderer); - Qt3DRender::QGeometry geometry; + Qt3DCore::QGeometry geometry; simulateInitializationSync(&geometry, &renderGeometry); diff --git a/tests/auto/render/geometryloaders/tst_geometryloaders.cpp b/tests/auto/render/geometryloaders/tst_geometryloaders.cpp index 07545403d..7fc914cda 100644 --- a/tests/auto/render/geometryloaders/tst_geometryloaders.cpp +++ b/tests/auto/render/geometryloaders/tst_geometryloaders.cpp @@ -42,14 +42,15 @@ #include #include -#include -#include +#include +#include #include #include #include "../../../../src/plugins/geometryloaders/qtgeometryloaders-config.h" +using namespace Qt3DCore; using namespace Qt3DRender; Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, geometryLoader, diff --git a/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp b/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp index 111b0a3ba..9d236b516 100644 --- a/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp +++ b/tests/auto/render/geometryrenderer/tst_geometryrenderer.cpp @@ -26,23 +26,19 @@ ** ****************************************************************************/ -// TODO Remove in Qt6 -#include -QT_WARNING_DISABLE_DEPRECATED - #include #include #include #include -#include +#include #include "testrenderer.h" -class DummyGeometry : public Qt3DRender::QGeometry +class DummyGeometry : public Qt3DCore::QGeometry { Q_OBJECT public: DummyGeometry(Qt3DCore::QNode *parent = nullptr) - : Qt3DRender::QGeometry(parent) + : Qt3DCore::QGeometry(parent) {} }; @@ -57,7 +53,7 @@ private Q_SLOTS: // GIVEN Qt3DRender::Render::GeometryRenderer renderGeometryRenderer; Qt3DRender::QGeometryRenderer geometryRenderer; - Qt3DRender::QGeometry geometry; + Qt3DCore::QGeometry geometry; Qt3DRender::Render::GeometryRendererManager geometryRendererManager; TestRenderer renderer; @@ -115,7 +111,7 @@ private Q_SLOTS: // GIVEN Qt3DRender::QGeometryRenderer geometryRenderer; - Qt3DRender::QGeometry geometry; + Qt3DCore::QGeometry geometry; TestRenderer renderer; geometryRenderer.setInstanceCount(454); diff --git a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp index 7f40fffcc..26dddf12f 100644 --- a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp +++ b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp @@ -56,8 +56,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -111,12 +111,12 @@ private: Qt3DCore::QComponent *comp2 = nullptr, Qt3DCore::QComponent *comp3 = nullptr, Qt3DCore::QEntity *parent = nullptr); - void addPositionAttributeToGeometry(Qt3DRender::QGeometry *geometry, - Qt3DRender::QBuffer *buffer, int count); - void addIndexAttributeToGeometry(Qt3DRender::QGeometry *geometry, - Qt3DRender::QBuffer *buffer, int count); - void addColorAttributeToGeometry(Qt3DRender::QGeometry *geometry, - Qt3DRender::QBuffer *buffer, int count); + void addPositionAttributeToGeometry(Qt3DCore::QGeometry *geometry, + Qt3DCore::QBuffer *buffer, int count); + void addIndexAttributeToGeometry(Qt3DCore::QGeometry *geometry, + Qt3DCore::QBuffer *buffer, int count); + void addColorAttributeToGeometry(Qt3DCore::QGeometry *geometry, + Qt3DCore::QBuffer *buffer, int count); Qt3DCore::QEntity *findChildEntity(Qt3DCore::QEntity *entity, const QString &name); Qt3DCore::QTransform *transformComponent(Qt3DCore::QEntity *entity); Qt3DRender::QAbstractLight *lightComponent(Qt3DCore::QEntity *entity); @@ -124,10 +124,10 @@ private: Qt3DRender::QGeometryRenderer *meshComponent(Qt3DCore::QEntity *entity); Qt3DRender::QMaterial *materialComponent(Qt3DCore::QEntity *entity); void compareComponents(Qt3DCore::QComponent *c1, Qt3DCore::QComponent *c2); - Qt3DRender::QAttribute *findAttribute(const QString &name, - Qt3DRender::QAttribute::AttributeType type, - Qt3DRender::QGeometry *geometry); - void compareAttributes(Qt3DRender::QAttribute *a1, Qt3DRender::QAttribute *a2); + Qt3DCore::QAttribute *findAttribute(const QString &name, + Qt3DCore::QAttribute::AttributeType type, + Qt3DCore::QGeometry *geometry); + void compareAttributes(Qt3DCore::QAttribute *a1, Qt3DCore::QAttribute *a2); void compareParameters(const QVector ¶ms1, const QVector ¶ms2); void compareRenderPasses(const QVector &passes1, @@ -515,8 +515,8 @@ void tst_gltfPlugins::createTestScene() transform->setRotation(Qt3DCore::QTransform::fromAxisAndAngle(1.0f, 1.0f, 1.0f, 270.0f)); Qt3DRender::QGeometryRenderer *boxMesh = createCustomCube(); - Qt3DRender::QBuffer *colorDataBuffer = - new Qt3DRender::QBuffer(boxMesh->geometry()); + Qt3DCore::QBuffer *colorDataBuffer = + new Qt3DCore::QBuffer(boxMesh->geometry()); QByteArray colorBufferData; colorBufferData.resize(8 * 4 * sizeof(float)); @@ -570,8 +570,8 @@ void tst_gltfPlugins::createTestScene() transform->setTranslation(QVector3D(0.0f, 2.0f, -40.0f)); transform->setRotation(Qt3DCore::QTransform::fromAxisAndAngle(1.0f, 2.0f, 3.0f, 90.0f)); Qt3DRender::QGeometryRenderer *boxMesh = createCustomCube(); - Qt3DRender::QBuffer *offsetBuffer = - new Qt3DRender::QBuffer(boxMesh->geometry()); + Qt3DCore::QBuffer *offsetBuffer = + new Qt3DCore::QBuffer(boxMesh->geometry()); QByteArray offsetBufferData; offsetBufferData.resize(8 * 3 * sizeof(float)); @@ -584,10 +584,10 @@ void tst_gltfPlugins::createTestScene() offsetBuffer->setData(offsetBufferData); - Qt3DRender::QAttribute *customAttribute = new Qt3DRender::QAttribute(); - customAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *customAttribute = new Qt3DCore::QAttribute(); + customAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); customAttribute->setBuffer(offsetBuffer); - customAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + customAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); customAttribute->setVertexSize(3); customAttribute->setByteOffset(0); customAttribute->setByteStride(0); @@ -614,29 +614,29 @@ void tst_gltfPlugins::createTestScene() #endif } -void tst_gltfPlugins::addPositionAttributeToGeometry(Qt3DRender::QGeometry *geometry, - Qt3DRender::QBuffer *buffer, int count) +void tst_gltfPlugins::addPositionAttributeToGeometry(Qt3DCore::QGeometry *geometry, + Qt3DCore::QBuffer *buffer, int count) { - Qt3DRender::QAttribute *posAttribute = new Qt3DRender::QAttribute(); - posAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *posAttribute = new Qt3DCore::QAttribute(); + posAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); posAttribute->setBuffer(buffer); - posAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + posAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); posAttribute->setVertexSize(3); posAttribute->setByteOffset(0); posAttribute->setByteStride(0); posAttribute->setCount(count); - posAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); + posAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); geometry->addAttribute(posAttribute); } -void tst_gltfPlugins::addIndexAttributeToGeometry(Qt3DRender::QGeometry *geometry, - Qt3DRender::QBuffer *buffer, int count) +void tst_gltfPlugins::addIndexAttributeToGeometry(Qt3DCore::QGeometry *geometry, + Qt3DCore::QBuffer *buffer, int count) { - Qt3DRender::QAttribute *indexAttribute = new Qt3DRender::QAttribute(); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + Qt3DCore::QAttribute *indexAttribute = new Qt3DCore::QAttribute(); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); indexAttribute->setBuffer(buffer); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); indexAttribute->setVertexSize(1); indexAttribute->setByteOffset(0); indexAttribute->setByteStride(0); @@ -645,18 +645,18 @@ void tst_gltfPlugins::addIndexAttributeToGeometry(Qt3DRender::QGeometry *geometr geometry->addAttribute(indexAttribute); } -void tst_gltfPlugins::addColorAttributeToGeometry(Qt3DRender::QGeometry *geometry, - Qt3DRender::QBuffer *buffer, int count) +void tst_gltfPlugins::addColorAttributeToGeometry(Qt3DCore::QGeometry *geometry, + Qt3DCore::QBuffer *buffer, int count) { - Qt3DRender::QAttribute *colorAttribute = new Qt3DRender::QAttribute(); - colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *colorAttribute = new Qt3DCore::QAttribute(); + colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); colorAttribute->setBuffer(buffer); - colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); colorAttribute->setVertexSize(4); colorAttribute->setByteOffset(0); colorAttribute->setByteStride(0); colorAttribute->setCount(count); - colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName()); + colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName()); geometry->addAttribute(colorAttribute); } @@ -736,46 +736,46 @@ void tst_gltfPlugins::compareComponents(Qt3DCore::QComponent *c1, Qt3DCore::QCom auto geometry2 = mesh2->geometry(); // Check that attributes match. compareAttributes( - findAttribute(Qt3DRender::QAttribute::defaultPositionAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultPositionAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry1), - findAttribute(Qt3DRender::QAttribute::defaultPositionAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultPositionAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry2)); compareAttributes( - findAttribute(Qt3DRender::QAttribute::defaultNormalAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultNormalAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry1), - findAttribute(Qt3DRender::QAttribute::defaultNormalAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultNormalAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry2)); compareAttributes( - findAttribute(Qt3DRender::QAttribute::defaultTangentAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultTangentAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry1), - findAttribute(Qt3DRender::QAttribute::defaultTangentAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultTangentAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry2)); compareAttributes( - findAttribute(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry1), - findAttribute(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry2)); compareAttributes( - findAttribute(Qt3DRender::QAttribute::defaultColorAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultColorAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry1), - findAttribute(Qt3DRender::QAttribute::defaultColorAttributeName(), - Qt3DRender::QAttribute::VertexAttribute, + findAttribute(Qt3DCore::QAttribute::defaultColorAttributeName(), + Qt3DCore::QAttribute::VertexAttribute, geometry2)); compareAttributes( findAttribute(QStringLiteral(""), - Qt3DRender::QAttribute::IndexAttribute, + Qt3DCore::QAttribute::IndexAttribute, geometry1), findAttribute(QStringLiteral(""), - Qt3DRender::QAttribute::IndexAttribute, + Qt3DCore::QAttribute::IndexAttribute, geometry2)); } else { int count = c1->metaObject()->propertyCount(); @@ -840,12 +840,12 @@ void tst_gltfPlugins::compareComponents(Qt3DCore::QComponent *c1, Qt3DCore::QCom } } -Qt3DRender::QAttribute *tst_gltfPlugins::findAttribute(const QString &name, - Qt3DRender::QAttribute::AttributeType type, - Qt3DRender::QGeometry *geometry) +Qt3DCore::QAttribute *tst_gltfPlugins::findAttribute(const QString &name, + Qt3DCore::QAttribute::AttributeType type, + Qt3DCore::QGeometry *geometry) { for (auto att : geometry->attributes()) { - if ((type == Qt3DRender::QAttribute::IndexAttribute && type == att->attributeType()) + if ((type == Qt3DCore::QAttribute::IndexAttribute && type == att->attributeType()) || name == att->name()) { return att; } @@ -853,7 +853,7 @@ Qt3DRender::QAttribute *tst_gltfPlugins::findAttribute(const QString &name, return nullptr; } -void tst_gltfPlugins::compareAttributes(Qt3DRender::QAttribute *a1, Qt3DRender::QAttribute *a2) +void tst_gltfPlugins::compareAttributes(Qt3DCore::QAttribute *a1, Qt3DCore::QAttribute *a2) { QCOMPARE(a1 == nullptr, a2 == nullptr); if (a1) { @@ -962,11 +962,11 @@ QUrl tst_gltfPlugins::getTextureUrl(Qt3DRender::QAbstractTexture *tex) Qt3DRender::QGeometryRenderer *tst_gltfPlugins::createCustomCube() { Qt3DRender::QGeometryRenderer *boxMesh = new Qt3DRender::QGeometryRenderer; - Qt3DRender::QGeometry *boxGeometry = new Qt3DRender::QGeometry(boxMesh); - Qt3DRender::QBuffer *boxDataBuffer = - new Qt3DRender::QBuffer(boxGeometry); - Qt3DRender::QBuffer *indexDataBuffer = - new Qt3DRender::QBuffer(boxGeometry); + Qt3DCore::QGeometry *boxGeometry = new Qt3DCore::QGeometry(boxMesh); + Qt3DCore::QBuffer *boxDataBuffer = + new Qt3DCore::QBuffer(boxGeometry); + Qt3DCore::QBuffer *indexDataBuffer = + new Qt3DCore::QBuffer(boxGeometry); QByteArray vertexBufferData; QByteArray indexBufferData; diff --git a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp index e8dfaa2cb..96341ce23 100644 --- a/tests/auto/render/meshfunctors/tst_meshfunctors.cpp +++ b/tests/auto/render/meshfunctors/tst_meshfunctors.cpp @@ -26,19 +26,14 @@ ** ****************************************************************************/ -// TODO Remove in Qt6 -#include -QT_WARNING_DISABLE_DEPRECATED - #include #include -#include -#include +#include #include #include #include -class MeshFunctorA : public Qt3DRender::QGeometryFactory +class MeshFunctorA : public Qt3DCore::QGeometryFactory { public: MeshFunctorA() @@ -47,20 +42,20 @@ public: ~MeshFunctorA() {} - Qt3DRender::QGeometry *operator ()() override + Qt3DCore::QGeometry *operator ()() override { return nullptr; } - bool operator ==(const Qt3DRender::QGeometryFactory &other) const override + bool operator ==(const Qt3DCore::QGeometryFactory &other) const override { - return Qt3DRender::functor_cast(&other); + return Qt3DCore::functor_cast(&other); } QT3D_FUNCTOR(MeshFunctorA) }; -class MeshFunctorB : public Qt3DRender::QGeometryFactory +class MeshFunctorB : public Qt3DCore::QGeometryFactory { public: MeshFunctorB() @@ -69,14 +64,14 @@ public: ~MeshFunctorB() {} - Qt3DRender::QGeometry *operator ()() override + Qt3DCore::QGeometry *operator ()() override { return nullptr; } - bool operator ==(const Qt3DRender::QGeometryFactory &other) const override + bool operator ==(const Qt3DCore::QGeometryFactory &other) const override { - return Qt3DRender::functor_cast(&other); + return Qt3DCore::functor_cast(&other); } QT3D_FUNCTOR(MeshFunctorB) @@ -91,9 +86,9 @@ public: ~MeshFunctorASub() {} - bool operator ==(const Qt3DRender::QGeometryFactory &other) const override + bool operator ==(const Qt3DCore::QGeometryFactory &other) const override { - return Qt3DRender::functor_cast(&other); + return Qt3DCore::functor_cast(&other); } QT3D_FUNCTOR(MeshFunctorASub) @@ -190,7 +185,7 @@ private Q_SLOTS: Qt3DRender::MeshLoaderFunctor functor(&mesh); // WHEN - const Qt3DRender::QGeometry *g = functor(); + const Qt3DCore::QGeometry *g = functor(); // THEN QVERIFY(g == nullptr); @@ -204,7 +199,7 @@ private Q_SLOTS: Qt3DRender::MeshLoaderFunctor functor(&mesh); // WHEN - const Qt3DRender::QGeometry *g = functor(); + const Qt3DCore::QGeometry *g = functor(); // THEN QVERIFY(g == nullptr); @@ -218,7 +213,7 @@ private Q_SLOTS: Qt3DRender::MeshLoaderFunctor functor(&mesh); // WHEN - const Qt3DRender::QGeometry *g = functor(); + const Qt3DCore::QGeometry *g = functor(); // THEN QVERIFY(g == nullptr); diff --git a/tests/auto/render/opengl/textures/tst_textures.cpp b/tests/auto/render/opengl/textures/tst_textures.cpp index 5fb00f23d..c9504cbbf 100644 --- a/tests/auto/render/opengl/textures/tst_textures.cpp +++ b/tests/auto/render/opengl/textures/tst_textures.cpp @@ -62,7 +62,7 @@ public: } bool operator ==(const Qt3DRender::QTextureImageDataGenerator &other) const override { - const TestImageDataGenerator *otherFunctor = Qt3DRender::functor_cast(&other); + const TestImageDataGenerator *otherFunctor = Qt3DCore::functor_cast(&other); return (otherFunctor != nullptr && otherFunctor->m_id == m_id); } @@ -83,7 +83,7 @@ public: } bool operator ==(const Qt3DRender::QTextureGenerator &other) const override { - const TestTextureGenerator *otherFunctor = Qt3DRender::functor_cast(&other); + const TestTextureGenerator *otherFunctor = Qt3DCore::functor_cast(&other); return (otherFunctor != nullptr && otherFunctor->m_id == m_id); } diff --git a/tests/auto/render/picking/tst_picking.cpp b/tests/auto/render/picking/tst_picking.cpp index acc9664bf..b38aa3695 100644 --- a/tests/auto/render/picking/tst_picking.cpp +++ b/tests/auto/render/picking/tst_picking.cpp @@ -36,8 +36,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -72,7 +72,7 @@ public: mesh->setRadius(radius); QSphereGeometry *g = static_cast(mesh->geometry()); QAttribute *positionAttr = static_cast(g->attributes().first()); - Qt3DRender::QBuffer *vertexBuffer = static_cast(positionAttr->buffer()); + Qt3DCore::QBuffer *vertexBuffer = static_cast(positionAttr->buffer()); transform->setTranslation(position); diff --git a/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp b/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp index 51b59bffc..ee0be6647 100644 --- a/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp +++ b/tests/auto/render/proximityfiltering/tst_proximityfiltering.cpp @@ -29,10 +29,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include #include @@ -53,13 +53,13 @@ Qt3DCore::QEntity *buildEntityAtDistance(float distance, Qt3DCore::QEntity *pare Qt3DCore::QEntity *entity = new Qt3DCore::QEntity(parent); // create geometry with a valid bounding volume - a single point is sufficient - auto geometry = new Qt3DRender::QGeometry; - auto vertexBuffer = new Qt3DRender::QBuffer(geometry); + auto geometry = new Qt3DCore::QGeometry; + auto vertexBuffer = new Qt3DCore::QBuffer(geometry); - auto positionAttribute = new Qt3DRender::QAttribute; - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + auto positionAttribute = new Qt3DCore::QAttribute; + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setByteStride(3 * sizeof(float)); positionAttribute->setBuffer(vertexBuffer); diff --git a/tests/auto/render/qattribute/tst_qattribute.cpp b/tests/auto/render/qattribute/tst_qattribute.cpp index 44793ce9f..8cc3f1b8c 100644 --- a/tests/auto/render/qattribute/tst_qattribute.cpp +++ b/tests/auto/render/qattribute/tst_qattribute.cpp @@ -30,9 +30,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "testarbiter.h" @@ -42,49 +42,49 @@ class tst_QAttribute: public QObject public: tst_QAttribute() { - qRegisterMetaType("Qt3DCore::QBuffer*"); + qRegisterMetaType("Qt3DCore::QBuffer*"); } private Q_SLOTS: void shouldHaveDefaultAttributeNames() { // GIVEN - Qt3DRender::QAttribute attribute; + Qt3DCore::QAttribute attribute; // THEN - QCOMPARE(Qt3DRender::QAttribute::defaultPositionAttributeName(), QStringLiteral("vertexPosition")); - QCOMPARE(Qt3DRender::QAttribute::defaultNormalAttributeName(), QStringLiteral("vertexNormal")); - QCOMPARE(Qt3DRender::QAttribute::defaultColorAttributeName(), QStringLiteral("vertexColor")); - QCOMPARE(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName(), QStringLiteral("vertexTexCoord")); - QCOMPARE(Qt3DRender::QAttribute::defaultTangentAttributeName(), QStringLiteral("vertexTangent")); - QCOMPARE(Qt3DRender::QAttribute::defaultJointIndicesAttributeName(), QStringLiteral("vertexJointIndices")); - QCOMPARE(Qt3DRender::QAttribute::defaultJointWeightsAttributeName(), QStringLiteral("vertexJointWeights")); + QCOMPARE(Qt3DCore::QAttribute::defaultPositionAttributeName(), QStringLiteral("vertexPosition")); + QCOMPARE(Qt3DCore::QAttribute::defaultNormalAttributeName(), QStringLiteral("vertexNormal")); + QCOMPARE(Qt3DCore::QAttribute::defaultColorAttributeName(), QStringLiteral("vertexColor")); + QCOMPARE(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName(), QStringLiteral("vertexTexCoord")); + QCOMPARE(Qt3DCore::QAttribute::defaultTangentAttributeName(), QStringLiteral("vertexTangent")); + QCOMPARE(Qt3DCore::QAttribute::defaultJointIndicesAttributeName(), QStringLiteral("vertexJointIndices")); + QCOMPARE(Qt3DCore::QAttribute::defaultJointWeightsAttributeName(), QStringLiteral("vertexJointWeights")); QCOMPARE(attribute.property("defaultPositionAttributeName").toString(), - Qt3DRender::QAttribute::defaultPositionAttributeName()); + Qt3DCore::QAttribute::defaultPositionAttributeName()); QCOMPARE(attribute.property("defaultNormalAttributeName").toString(), - Qt3DRender::QAttribute::defaultNormalAttributeName()); + Qt3DCore::QAttribute::defaultNormalAttributeName()); QCOMPARE(attribute.property("defaultColorAttributeName").toString(), - Qt3DRender::QAttribute::defaultColorAttributeName()); + Qt3DCore::QAttribute::defaultColorAttributeName()); QCOMPARE(attribute.property("defaultTextureCoordinateAttributeName").toString(), - Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); + Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); QCOMPARE(attribute.property("defaultTangentAttributeName").toString(), - Qt3DRender::QAttribute::defaultTangentAttributeName()); + Qt3DCore::QAttribute::defaultTangentAttributeName()); QCOMPARE(attribute.property("defaultJointIndicesAttributeName").toString(), - Qt3DRender::QAttribute::defaultJointIndicesAttributeName()); + Qt3DCore::QAttribute::defaultJointIndicesAttributeName()); QCOMPARE(attribute.property("defaultJointWeightsAttributeName").toString(), - Qt3DRender::QAttribute::defaultJointWeightsAttributeName()); + Qt3DCore::QAttribute::defaultJointWeightsAttributeName()); } void checkPropertyUpdates() { // GIVEN TestArbiter arbiter; - QScopedPointer attribute(new Qt3DRender::QAttribute()); + QScopedPointer attribute(new Qt3DCore::QAttribute()); arbiter.setArbiterOnNode(attribute.data()); // WHEN - attribute->setVertexBaseType(Qt3DRender::QAttribute::Double); + attribute->setVertexBaseType(Qt3DCore::QAttribute::Double); // THEN QCOMPARE(arbiter.dirtyNodes().size(), 1); @@ -147,7 +147,7 @@ private Q_SLOTS: arbiter.clear(); // WHEN - attribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + attribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); // THEN QCOMPARE(arbiter.dirtyNodes().size(), 1); @@ -156,7 +156,7 @@ private Q_SLOTS: arbiter.clear(); // WHEN - Qt3DRender::QBuffer buf; + Qt3DCore::QBuffer buf; attribute->setBuffer(&buf); // THEN @@ -166,7 +166,7 @@ private Q_SLOTS: arbiter.clear(); // WHEN - Qt3DRender::QBuffer buf2; + Qt3DCore::QBuffer buf2; attribute->setBuffer(&buf2); // THEN @@ -179,10 +179,10 @@ private Q_SLOTS: void checkBufferBookkeeping() { // GIVEN - QScopedPointer attribute(new Qt3DRender::QAttribute); + QScopedPointer attribute(new Qt3DCore::QAttribute); { // WHEN - Qt3DRender::QBuffer buf; + Qt3DCore::QBuffer buf; attribute->setBuffer(&buf); // THEN @@ -194,8 +194,8 @@ private Q_SLOTS: { // WHEN - Qt3DRender::QAttribute someOtherAttribute; - QScopedPointer buf(new Qt3DRender::QBuffer(&someOtherAttribute)); + Qt3DCore::QAttribute someOtherAttribute; + QScopedPointer buf(new Qt3DCore::QBuffer(&someOtherAttribute)); attribute->setBuffer(buf.data()); // THEN diff --git a/tests/auto/render/qbuffer/tst_qbuffer.cpp b/tests/auto/render/qbuffer/tst_qbuffer.cpp index 34cfe4941..d5c5f1b3a 100644 --- a/tests/auto/render/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/render/qbuffer/tst_qbuffer.cpp @@ -26,16 +26,12 @@ ** ****************************************************************************/ -// TODO Remove in Qt6 -#include -QT_WARNING_DISABLE_DEPRECATED - #include #include #include -#include -#include +#include +#include #include "testarbiter.h" @@ -49,11 +45,11 @@ private Q_SLOTS: { // GIVEN TestArbiter arbiter; - QScopedPointer buffer(new Qt3DRender::QBuffer); + QScopedPointer buffer(new Qt3DCore::QBuffer); arbiter.setArbiterOnNode(buffer.data()); // WHEN - buffer->setUsage(Qt3DRender::QBuffer::DynamicCopy); + buffer->setUsage(Qt3DCore::QBuffer::DynamicCopy); // THEN QCOMPARE(arbiter.dirtyNodes().size(), 1); diff --git a/tests/auto/render/qgeometry/tst_qgeometry.cpp b/tests/auto/render/qgeometry/tst_qgeometry.cpp index 30092b204..59684567b 100644 --- a/tests/auto/render/qgeometry/tst_qgeometry.cpp +++ b/tests/auto/render/qgeometry/tst_qgeometry.cpp @@ -30,16 +30,16 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include "testarbiter.h" -class FakeGeometry : public Qt3DRender::QGeometry +class FakeGeometry : public Qt3DCore::QGeometry { Q_OBJECT }; @@ -54,11 +54,11 @@ private Q_SLOTS: { // GIVEN TestArbiter arbiter; - QScopedPointer geometry(new Qt3DRender::QGeometry()); + QScopedPointer geometry(new Qt3DCore::QGeometry()); arbiter.setArbiterOnNode(geometry.data()); // WHEN - Qt3DRender::QAttribute attr; + Qt3DCore::QAttribute attr; geometry->addAttribute(&attr); QCoreApplication::processEvents(); @@ -87,10 +87,10 @@ private Q_SLOTS: void checkAttributeBookkeeping() { // GIVEN - QScopedPointer geometry(new Qt3DRender::QGeometry); + QScopedPointer geometry(new Qt3DCore::QGeometry); { // WHEN - Qt3DRender::QAttribute attribute; + Qt3DCore::QAttribute attribute; geometry->addAttribute(&attribute); // THEN @@ -102,8 +102,8 @@ private Q_SLOTS: { // WHEN - Qt3DRender::QGeometry someOtherGeometry; - QScopedPointer attribute(new Qt3DRender::QAttribute(&someOtherGeometry)); + Qt3DCore::QGeometry someOtherGeometry; + QScopedPointer attribute(new Qt3DCore::QAttribute(&someOtherGeometry)); geometry->addAttribute(attribute.data()); // THEN @@ -134,7 +134,7 @@ private Q_SLOTS: QCOMPARE(geometry->maxExtent(), QVector3D()); // WHEN - auto dNode = static_cast(Qt3DCore::QNodePrivate::get(geometry.data())); + auto dNode = static_cast(Qt3DCore::QNodePrivate::get(geometry.data())); const QVector3D minExt(-1.0f, -1.0f, -1.0f); const QVector3D maxExt(1.0f, 1.0f, 1.0f); dNode->setExtent(minExt, maxExt); diff --git a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp index 76f913af7..f3560e353 100644 --- a/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp +++ b/tests/auto/render/qgeometryrenderer/tst_qgeometryrenderer.cpp @@ -26,18 +26,14 @@ ** ****************************************************************************/ -// TODO Remove in Qt6 -#include -QT_WARNING_DISABLE_DEPRECATED - #include #include #include #include -#include -#include -#include +#include +#include +#include #include #include "testarbiter.h" @@ -146,7 +142,7 @@ private Q_SLOTS: arbiter.clear(); // WHEN - Qt3DRender::QGeometry geom; + Qt3DCore::QGeometry geom; geometryRenderer->setGeometry(&geom); QCoreApplication::processEvents(); @@ -157,7 +153,7 @@ private Q_SLOTS: arbiter.clear(); // WHEN - Qt3DRender::QGeometry geom2; + Qt3DCore::QGeometry geom2; geometryRenderer->setGeometry(&geom2); QCoreApplication::processEvents(); @@ -174,7 +170,7 @@ private Q_SLOTS: QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer); { // WHEN - Qt3DRender::QGeometry geometry; + Qt3DCore::QGeometry geometry; geometryRenderer->setGeometry(&geometry); // THEN @@ -187,7 +183,7 @@ private Q_SLOTS: { // WHEN Qt3DRender::QGeometryRenderer someOtherGeometryRenderer; - QScopedPointer geometry(new Qt3DRender::QGeometry(&someOtherGeometryRenderer)); + QScopedPointer geometry(new Qt3DCore::QGeometry(&someOtherGeometryRenderer)); geometryRenderer->setGeometry(geometry.data()); // THEN diff --git a/tests/auto/render/scene2d/tst_scene2d.cpp b/tests/auto/render/scene2d/tst_scene2d.cpp index 4b4ba03f0..bf9e70879 100644 --- a/tests/auto/render/scene2d/tst_scene2d.cpp +++ b/tests/auto/render/scene2d/tst_scene2d.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -211,11 +211,11 @@ private Q_SLOTS: TestRenderer renderer; QScopedPointer scene2d(new Scene2D()); QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); Qt3DRender::QGeometryRenderer *geometryRenderer = new Qt3DRender::QGeometryRenderer(); - Qt3DRender::QAttribute *positionAttribute = new Qt3DRender::QAttribute(); - Qt3DRender::QAttribute *texcoordAttribute = new Qt3DRender::QAttribute(); - Qt3DRender::QBuffer *dataBuffer =new Qt3DRender::QBuffer(); + Qt3DCore::QAttribute *positionAttribute = new Qt3DCore::QAttribute(); + Qt3DCore::QAttribute *texcoordAttribute = new Qt3DCore::QAttribute(); + Qt3DCore::QBuffer *dataBuffer =new Qt3DCore::QBuffer(); QScopedPointer entity(new Qt3DCore::QEntity()); entity->addComponent(geometryRenderer); renderer.setNodeManagers(nodeManagers.data()); @@ -272,23 +272,23 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer, backendBuffer); positionAttribute->setBuffer(dataBuffer); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(sizeof(float) * 5); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute); texcoordAttribute->setBuffer(dataBuffer); - texcoordAttribute->setName(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName()); - texcoordAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + texcoordAttribute->setName(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName()); + texcoordAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); texcoordAttribute->setVertexSize(2); texcoordAttribute->setCount(6); texcoordAttribute->setByteStride(sizeof(float) * 5); texcoordAttribute->setByteOffset(sizeof(float) * 3); - texcoordAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + texcoordAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(texcoordAttribute); geometryRenderer->setGeometry(geometry); diff --git a/tests/auto/render/segmentvisitor/tst_segmentvisitor.cpp b/tests/auto/render/segmentvisitor/tst_segmentvisitor.cpp index fc65d0854..7283f7a0a 100644 --- a/tests/auto/render/segmentvisitor/tst_segmentvisitor.cpp +++ b/tests/auto/render/segmentvisitor/tst_segmentvisitor.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -150,10 +150,10 @@ private Q_SLOTS: void testVisitSegments() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -188,13 +188,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -226,12 +226,12 @@ private Q_SLOTS: void testVisitSegmentsIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -277,18 +277,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(2*5); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -328,10 +328,10 @@ private Q_SLOTS: void testVisitLineStrip() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -357,13 +357,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -395,12 +395,12 @@ private Q_SLOTS: void testVisitListStripIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -443,18 +443,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(7); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -495,10 +495,10 @@ private Q_SLOTS: void testVisitLineLoop() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -524,13 +524,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -563,12 +563,12 @@ private Q_SLOTS: void testVisitLineLoopIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -612,18 +612,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(8); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -667,10 +667,10 @@ private Q_SLOTS: void testVisitLineAdjacency() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -697,13 +697,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -733,12 +733,12 @@ private Q_SLOTS: void testVisitLinesAdjacencyIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -779,18 +779,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(4); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(4); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); diff --git a/tests/auto/render/trianglevisitor/tst_trianglevisitor.cpp b/tests/auto/render/trianglevisitor/tst_trianglevisitor.cpp index 66f67e08a..058df8887 100644 --- a/tests/auto/render/trianglevisitor/tst_trianglevisitor.cpp +++ b/tests/auto/render/trianglevisitor/tst_trianglevisitor.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -154,10 +154,10 @@ private Q_SLOTS: void testVisitTriangles() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -190,13 +190,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(0); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -227,12 +227,12 @@ private Q_SLOTS: void testVisitTrianglesIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -290,18 +290,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(3*5); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -341,10 +341,10 @@ private Q_SLOTS: void testVisitTriangleStrip() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -377,13 +377,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -416,12 +416,12 @@ private Q_SLOTS: void testVisitTriangleStripIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -480,18 +480,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(4*4); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -537,10 +537,10 @@ private Q_SLOTS: void testVisitTriangleFan() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -573,13 +573,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -612,12 +612,12 @@ private Q_SLOTS: void testVisitTriangleFanIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -670,18 +670,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(10); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -723,10 +723,10 @@ private Q_SLOTS: void testVisitTrianglesAdjacency() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -759,13 +759,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -795,12 +795,12 @@ private Q_SLOTS: void testVisitTrianglesAdjacencyIndexed() { QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -856,18 +856,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(3*4); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); @@ -905,10 +905,10 @@ private Q_SLOTS: { QSKIP("TriangleStripAdjacency not implemented"); QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -953,13 +953,13 @@ private Q_SLOTS: simulateInitializationSync(dataBuffer.data(), backendBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(8); positionAttribute->setByteStride(3*4); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); geometry->addAttribute(positionAttribute.data()); geometryRenderer->setGeometry(geometry); @@ -991,12 +991,12 @@ private Q_SLOTS: { QSKIP("TriangleStripAdjacency not implemented"); QScopedPointer nodeManagers(new NodeManagers()); - Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry(); + Qt3DCore::QGeometry *geometry = new Qt3DCore::QGeometry(); QScopedPointer geometryRenderer(new Qt3DRender::QGeometryRenderer()); - QScopedPointer positionAttribute(new Qt3DRender::QAttribute()); - QScopedPointer indexAttribute(new Qt3DRender::QAttribute()); - QScopedPointer dataBuffer(new Qt3DRender::QBuffer()); - QScopedPointer indexDataBuffer(new Qt3DRender::QBuffer()); + QScopedPointer positionAttribute(new Qt3DCore::QAttribute()); + QScopedPointer indexAttribute(new Qt3DCore::QAttribute()); + QScopedPointer dataBuffer(new Qt3DCore::QBuffer()); + QScopedPointer indexDataBuffer(new Qt3DCore::QBuffer()); TestVisitor visitor(nodeManagers.data()); TestRenderer renderer; @@ -1047,18 +1047,18 @@ private Q_SLOTS: simulateInitializationSync(indexDataBuffer.data(), backendIndexBuffer); positionAttribute->setBuffer(dataBuffer.data()); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setCount(6); positionAttribute->setByteStride(3*sizeof(float)); positionAttribute->setByteOffset(0); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); indexAttribute->setBuffer(indexDataBuffer.data()); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt); indexAttribute->setCount(8); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); geometry->addAttribute(positionAttribute.data()); geometry->addAttribute(indexAttribute.data()); diff --git a/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp b/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp index ae2218739..a0af5cea5 100644 --- a/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp +++ b/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp @@ -146,8 +146,8 @@ struct NodeCollection { explicit NodeCollection(Qt3DRender::TestAspect *aspect, QObject *frontendRoot) : geometryRenderers(frontendRoot->findChildren()) - , attributes(frontendRoot->findChildren()) - , buffers(frontendRoot->findChildren()) + , attributes(frontendRoot->findChildren()) + , buffers(frontendRoot->findChildren()) { // THEN QCOMPARE(aspect->nodeManagers()->geometryManager()->activeHandles().size(), geometryRenderers.size()); @@ -160,13 +160,13 @@ struct NodeCollection backendGeometryRenderer.push_back(backend); } - for (const Qt3DRender::QAttribute *a : qAsConst(attributes)) { + for (const Qt3DCore::QAttribute *a : qAsConst(attributes)) { Qt3DRender::Render::Attribute *backend = aspect->nodeManagers()->attributeManager()->lookupResource(a->id()); QVERIFY(backend != nullptr); backendAttributes.push_back(backend); } - for (const Qt3DRender::QBuffer *b : qAsConst(buffers)) { + for (const Qt3DCore::QBuffer *b : qAsConst(buffers)) { Qt3DRender::Render::Buffer *backend = aspect->nodeManagers()->bufferManager()->lookupResource(b->id()); QVERIFY(backend != nullptr); backendBuffers.push_back(backend); @@ -174,8 +174,8 @@ struct NodeCollection } QList geometryRenderers; - QList attributes; - QList buffers; + QList attributes; + QList buffers; QVector backendGeometryRenderer; QVector backendAttributes; diff --git a/tests/manual/buffercapture-qml/main.cpp b/tests/manual/buffercapture-qml/main.cpp index 6928c5724..278646a3c 100644 --- a/tests/manual/buffercapture-qml/main.cpp +++ b/tests/manual/buffercapture-qml/main.cpp @@ -67,9 +67,9 @@ int main(int argc, char* argv[]) view.setSource(QUrl("qrc:/main.qml")); QObject *rootObject = view.rootObject(); - Qt3DRender::QBuffer *buffer = rootObject->findChild("buffer"); + Qt3DCore::QBuffer *buffer = rootObject->findChild("buffer"); - QObject::connect(buffer, &Qt3DRender::QBuffer::dataChanged, + QObject::connect(buffer, &Qt3DCore::QBuffer::dataChanged, [=](const QByteArray &bytes) { //I know I'm receiving int data const uint *data = reinterpret_cast(bytes.data()); diff --git a/tests/manual/custom-mesh-cpp-indirect/main.cpp b/tests/manual/custom-mesh-cpp-indirect/main.cpp index 3e26e3d10..0cb19f8b2 100644 --- a/tests/manual/custom-mesh-cpp-indirect/main.cpp +++ b/tests/manual/custom-mesh-cpp-indirect/main.cpp @@ -55,6 +55,9 @@ #include #include #include +#include +#include +#include #include @@ -64,9 +67,6 @@ #include #include -#include -#include -#include #include #include @@ -166,11 +166,11 @@ int main(int argc, char* argv[]) // Custom Mesh (TetraHedron) Qt3DRender::QGeometryRenderer *customMeshRenderer = new Qt3DRender::QGeometryRenderer; - Qt3DRender::QGeometry *customGeometry = new Qt3DRender::QGeometry(customMeshRenderer); + Qt3DCore::QGeometry *customGeometry = new Qt3DCore::QGeometry(customMeshRenderer); - Qt3DRender::QBuffer *vertexDataBuffer = new Qt3DRender::QBuffer(customGeometry); - Qt3DRender::QBuffer *indexDataBuffer = new Qt3DRender::QBuffer(customGeometry); - Qt3DRender::QBuffer *indirectDrawDataBuffer = new Qt3DRender::QBuffer(customGeometry); + Qt3DCore::QBuffer *vertexDataBuffer = new Qt3DCore::QBuffer(customGeometry); + Qt3DCore::QBuffer *indexDataBuffer = new Qt3DCore::QBuffer(customGeometry); + Qt3DCore::QBuffer *indirectDrawDataBuffer = new Qt3DCore::QBuffer(customGeometry); // 4 distinct vertices QByteArray vertexBufferData; @@ -222,47 +222,47 @@ int main(int argc, char* argv[]) indirectDrawDataBuffer->setData(indirectBufferData); // Attributes - Qt3DRender::QAttribute *positionAttribute = new Qt3DRender::QAttribute(); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *positionAttribute = new Qt3DCore::QAttribute(); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); positionAttribute->setBuffer(vertexDataBuffer); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setByteOffset(0); positionAttribute->setByteStride(9 * sizeof(float)); positionAttribute->setCount(4); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); - Qt3DRender::QAttribute *normalAttribute = new Qt3DRender::QAttribute(); - normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *normalAttribute = new Qt3DCore::QAttribute(); + normalAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); normalAttribute->setBuffer(vertexDataBuffer); - normalAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + normalAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); normalAttribute->setVertexSize(3); normalAttribute->setByteOffset(3 * sizeof(float)); normalAttribute->setByteStride(9 * sizeof(float)); normalAttribute->setCount(4); - normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); + normalAttribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName()); - Qt3DRender::QAttribute *colorAttribute = new Qt3DRender::QAttribute(); - colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *colorAttribute = new Qt3DCore::QAttribute(); + colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); colorAttribute->setBuffer(vertexDataBuffer); - colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); colorAttribute->setVertexSize(3); colorAttribute->setByteOffset(6 * sizeof(float)); colorAttribute->setByteStride(9 * sizeof(float)); colorAttribute->setCount(4); - colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName()); + colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName()); - Qt3DRender::QAttribute *indexAttribute = new Qt3DRender::QAttribute(); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + Qt3DCore::QAttribute *indexAttribute = new Qt3DCore::QAttribute(); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); indexAttribute->setBuffer(indexDataBuffer); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); indexAttribute->setVertexSize(1); indexAttribute->setByteOffset(0); indexAttribute->setByteStride(0); indexAttribute->setCount(12); - Qt3DRender::QAttribute *indirectAttribute = new Qt3DRender::QAttribute(); - indirectAttribute->setAttributeType(Qt3DRender::QAttribute::DrawIndirectAttribute); + Qt3DCore::QAttribute *indirectAttribute = new Qt3DCore::QAttribute(); + indirectAttribute->setAttributeType(Qt3DCore::QAttribute::DrawIndirectAttribute); indirectAttribute->setBuffer(indirectDrawDataBuffer); indirectAttribute->setByteOffset(0); indirectAttribute->setByteStride(0); @@ -298,10 +298,10 @@ int main(int argc, char* argv[]) // Custom Mesh (TetraHedron) Qt3DRender::QGeometryRenderer *customMeshRenderer = new Qt3DRender::QGeometryRenderer; - Qt3DRender::QGeometry *customGeometry = new Qt3DRender::QGeometry(customMeshRenderer); + Qt3DCore::QGeometry *customGeometry = new Qt3DCore::QGeometry(customMeshRenderer); - Qt3DRender::QBuffer *vertexDataBuffer = new Qt3DRender::QBuffer(customGeometry); - Qt3DRender::QBuffer *indirectDrawDataBuffer = new Qt3DRender::QBuffer(customGeometry); + Qt3DCore::QBuffer *vertexDataBuffer = new Qt3DCore::QBuffer(customGeometry); + Qt3DCore::QBuffer *indirectDrawDataBuffer = new Qt3DCore::QBuffer(customGeometry); QVector orderedPositionVertices; @@ -340,38 +340,38 @@ int main(int argc, char* argv[]) indirectDrawDataBuffer->setData(indirectBufferData); // Attributes - Qt3DRender::QAttribute *positionAttribute = new Qt3DRender::QAttribute(); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *positionAttribute = new Qt3DCore::QAttribute(); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); positionAttribute->setBuffer(vertexDataBuffer); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setByteOffset(0); positionAttribute->setByteStride(9 * sizeof(float)); positionAttribute->setCount(12); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); - Qt3DRender::QAttribute *normalAttribute = new Qt3DRender::QAttribute(); - normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *normalAttribute = new Qt3DCore::QAttribute(); + normalAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); normalAttribute->setBuffer(vertexDataBuffer); - normalAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + normalAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); normalAttribute->setVertexSize(3); normalAttribute->setByteOffset(3 * sizeof(float)); normalAttribute->setByteStride(9 * sizeof(float)); normalAttribute->setCount(12); - normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); + normalAttribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName()); - Qt3DRender::QAttribute *colorAttribute = new Qt3DRender::QAttribute(); - colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *colorAttribute = new Qt3DCore::QAttribute(); + colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); colorAttribute->setBuffer(vertexDataBuffer); - colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); colorAttribute->setVertexSize(3); colorAttribute->setByteOffset(6 * sizeof(float)); colorAttribute->setByteStride(9 * sizeof(float)); colorAttribute->setCount(12); - colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName()); + colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName()); - Qt3DRender::QAttribute *indirectAttribute = new Qt3DRender::QAttribute(); - indirectAttribute->setAttributeType(Qt3DRender::QAttribute::DrawIndirectAttribute); + Qt3DCore::QAttribute *indirectAttribute = new Qt3DCore::QAttribute(); + indirectAttribute->setAttributeType(Qt3DCore::QAttribute::DrawIndirectAttribute); indirectAttribute->setBuffer(indirectDrawDataBuffer); indirectAttribute->setByteOffset(0); indirectAttribute->setByteStride(0); diff --git a/tests/manual/custom-mesh-cpp/main.cpp b/tests/manual/custom-mesh-cpp/main.cpp index 275d97088..dee8363d8 100644 --- a/tests/manual/custom-mesh-cpp/main.cpp +++ b/tests/manual/custom-mesh-cpp/main.cpp @@ -55,6 +55,9 @@ #include #include #include +#include +#include +#include #include @@ -64,9 +67,6 @@ #include #include -#include -#include -#include #include #include @@ -105,10 +105,10 @@ int main(int argc, char* argv[]) // Custom Mesh (TetraHedron) Qt3DRender::QGeometryRenderer *customMeshRenderer = new Qt3DRender::QGeometryRenderer; - Qt3DRender::QGeometry *customGeometry = new Qt3DRender::QGeometry(customMeshRenderer); + Qt3DCore::QGeometry *customGeometry = new Qt3DCore::QGeometry(customMeshRenderer); - Qt3DRender::QBuffer *vertexDataBuffer = new Qt3DRender::QBuffer(customGeometry); - Qt3DRender::QBuffer *indexDataBuffer = new Qt3DRender::QBuffer(customGeometry); + Qt3DCore::QBuffer *vertexDataBuffer = new Qt3DCore::QBuffer(customGeometry); + Qt3DCore::QBuffer *indexDataBuffer = new Qt3DCore::QBuffer(customGeometry); // vec3 for position // vec3 for colors @@ -190,40 +190,40 @@ int main(int argc, char* argv[]) indexDataBuffer->setData(indexBufferData); // Attributes - Qt3DRender::QAttribute *positionAttribute = new Qt3DRender::QAttribute(); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *positionAttribute = new Qt3DCore::QAttribute(); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); positionAttribute->setBuffer(vertexDataBuffer); - positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); positionAttribute->setVertexSize(3); positionAttribute->setByteOffset(0); positionAttribute->setByteStride(9 * sizeof(float)); positionAttribute->setCount(4); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); - Qt3DRender::QAttribute *normalAttribute = new Qt3DRender::QAttribute(); - normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *normalAttribute = new Qt3DCore::QAttribute(); + normalAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); normalAttribute->setBuffer(vertexDataBuffer); - normalAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + normalAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); normalAttribute->setVertexSize(3); normalAttribute->setByteOffset(3 * sizeof(float)); normalAttribute->setByteStride(9 * sizeof(float)); normalAttribute->setCount(4); - normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); + normalAttribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName()); - Qt3DRender::QAttribute *colorAttribute = new Qt3DRender::QAttribute(); - colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *colorAttribute = new Qt3DCore::QAttribute(); + colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); colorAttribute->setBuffer(vertexDataBuffer); - colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); colorAttribute->setVertexSize(3); colorAttribute->setByteOffset(6 * sizeof(float)); colorAttribute->setByteStride(9 * sizeof(float)); colorAttribute->setCount(4); - colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName()); + colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName()); - Qt3DRender::QAttribute *indexAttribute = new Qt3DRender::QAttribute(); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + Qt3DCore::QAttribute *indexAttribute = new Qt3DCore::QAttribute(); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); indexAttribute->setBuffer(indexDataBuffer); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); indexAttribute->setVertexSize(1); indexAttribute->setByteOffset(0); indexAttribute->setByteStride(0); diff --git a/tests/manual/custom-mesh-update-data-cpp/main.cpp b/tests/manual/custom-mesh-update-data-cpp/main.cpp index 2b6b6b3cf..9f997658b 100644 --- a/tests/manual/custom-mesh-update-data-cpp/main.cpp +++ b/tests/manual/custom-mesh-update-data-cpp/main.cpp @@ -56,6 +56,9 @@ #include #include #include +#include +#include +#include #include @@ -65,9 +68,6 @@ #include #include -#include -#include -#include #include #include @@ -75,7 +75,7 @@ #include QByteArray vertexBufferData; -Qt3DRender::QBuffer *vertexDataBuffer; +Qt3DCore::QBuffer *vertexDataBuffer; class TimerObject: public QObject { Q_OBJECT @@ -124,10 +124,10 @@ int main(int argc, char* argv[]) // Custom Mesh (TetraHedron) Qt3DRender::QGeometryRenderer *customMeshRenderer = new Qt3DRender::QGeometryRenderer; - Qt3DRender::QGeometry *customGeometry = new Qt3DRender::QGeometry(customMeshRenderer); + Qt3DCore::QGeometry *customGeometry = new Qt3DCore::QGeometry(customMeshRenderer); - vertexDataBuffer = new Qt3DRender::QBuffer(customGeometry); - Qt3DRender::QBuffer *indexDataBuffer = new Qt3DRender::QBuffer(customGeometry); + vertexDataBuffer = new Qt3DCore::QBuffer(customGeometry); + Qt3DCore::QBuffer *indexDataBuffer = new Qt3DCore::QBuffer(customGeometry); // vec3 for position // vec3 for colors @@ -208,37 +208,37 @@ int main(int argc, char* argv[]) indexDataBuffer->setData(indexBufferData); // Attributes - Qt3DRender::QAttribute *positionAttribute = new Qt3DRender::QAttribute(); - positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *positionAttribute = new Qt3DCore::QAttribute(); + positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); positionAttribute->setBuffer(vertexDataBuffer); positionAttribute->setVertexSize(3); positionAttribute->setByteOffset(0); positionAttribute->setByteStride(9 * sizeof(float)); positionAttribute->setCount(4); - positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); + positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); - Qt3DRender::QAttribute *normalAttribute = new Qt3DRender::QAttribute(); - normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *normalAttribute = new Qt3DCore::QAttribute(); + normalAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); normalAttribute->setBuffer(vertexDataBuffer); normalAttribute->setVertexSize(3); normalAttribute->setByteOffset(3 * sizeof(float)); normalAttribute->setByteStride(9 * sizeof(float)); normalAttribute->setCount(4); - normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName()); + normalAttribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName()); - Qt3DRender::QAttribute *colorAttribute = new Qt3DRender::QAttribute(); - colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute); + Qt3DCore::QAttribute *colorAttribute = new Qt3DCore::QAttribute(); + colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute); colorAttribute->setBuffer(vertexDataBuffer); colorAttribute->setVertexSize(3); colorAttribute->setByteOffset(6 * sizeof(float)); colorAttribute->setByteStride(9 * sizeof(float)); colorAttribute->setCount(4); - colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName()); + colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName()); - Qt3DRender::QAttribute *indexAttribute = new Qt3DRender::QAttribute(); - indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); + Qt3DCore::QAttribute *indexAttribute = new Qt3DCore::QAttribute(); + indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute); indexAttribute->setBuffer(indexDataBuffer); - indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedShort); indexAttribute->setVertexSize(1); indexAttribute->setByteOffset(0); indexAttribute->setByteStride(0); diff --git a/tests/manual/mesh-morphing/main.cpp b/tests/manual/mesh-morphing/main.cpp index 641722a4c..a2c9dfc17 100644 --- a/tests/manual/mesh-morphing/main.cpp +++ b/tests/manual/mesh-morphing/main.cpp @@ -108,8 +108,8 @@ int main(int argc, char **argv) cylinder3->setRadius(1.0f); QStringList attributes; - attributes.push_back(Qt3DRender::QAttribute::defaultPositionAttributeName()); - attributes.push_back(Qt3DRender::QAttribute::defaultNormalAttributeName()); + attributes.push_back(Qt3DCore::QAttribute::defaultPositionAttributeName()); + attributes.push_back(Qt3DCore::QAttribute::defaultNormalAttributeName()); QVector morphTargets; morphTargets.push_back(Qt3DAnimation::QMorphTarget::fromGeometry(cylinder1, attributes)); diff --git a/tests/manual/tessellation-modes/tessellatedquadmesh.cpp b/tests/manual/tessellation-modes/tessellatedquadmesh.cpp index 8e9a09d98..f5980f056 100644 --- a/tests/manual/tessellation-modes/tessellatedquadmesh.cpp +++ b/tests/manual/tessellation-modes/tessellatedquadmesh.cpp @@ -50,18 +50,18 @@ #include "tessellatedquadmesh.h" -#include -#include -#include +#include +#include +#include -class TessellatedGeometry : public Qt3DRender::QGeometry +class TessellatedGeometry : public Qt3DCore::QGeometry { Q_OBJECT public: TessellatedGeometry(Qt3DCore::QNode *parent = nullptr) - : Qt3DRender::QGeometry(parent) - , m_positionAttribute(new Qt3DRender::QAttribute(this)) - , m_vertexBuffer(new Qt3DRender::QBuffer(this)) + : Qt3DCore::QGeometry(parent) + , m_positionAttribute(new Qt3DCore::QAttribute(this)) + , m_vertexBuffer(new Qt3DCore::QBuffer(this)) { const float positionData[] = { -0.8f, -0.8f, 0.0f, @@ -78,8 +78,8 @@ public: m_vertexBuffer->setData(positionBytes); - m_positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - m_positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float); + m_positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName()); + m_positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float); m_positionAttribute->setVertexSize(3); m_positionAttribute->setCount(nVerts); m_positionAttribute->setByteStride(3 * sizeof(float)); @@ -89,8 +89,8 @@ public: } private: - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; + Qt3DCore::QAttribute *m_positionAttribute; + Qt3DCore::QBuffer *m_vertexBuffer; }; TessellatedQuadMesh::TessellatedQuadMesh(Qt3DCore::QNode *parent) -- cgit v1.2.3