diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2014-10-20 08:44:50 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2014-10-22 10:45:16 +0200 |
commit | 5d31b5f774475f87a00447c4eac6eb96e9651675 (patch) | |
tree | e0206fbc355033b2d41a2ef423feb5c8fc488e8e | |
parent | 0c8a6df93997e7aba0c8269ce986bd8fe4168d5b (diff) |
QAbstractMeshData merged with QMeshData and moved to Renderer
That implied moving QAbstractMesh to Renderer as well.
Change-Id: I9013bf0458b849f7805d214a70580a80e86d8c84
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
40 files changed, 263 insertions, 486 deletions
diff --git a/examples/tessellation-modes/tessellatedquadmesh.cpp b/examples/tessellation-modes/tessellatedquadmesh.cpp index f35ed81f3..b6dfe2cf2 100644 --- a/examples/tessellation-modes/tessellatedquadmesh.cpp +++ b/examples/tessellation-modes/tessellatedquadmesh.cpp @@ -55,7 +55,7 @@ class TessellatedQuadMeshFunctor : public Qt3D::QAbstractMeshFunctor public: TessellatedQuadMeshFunctor() {} - Qt3D::QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE + Qt3D::QMeshDataPtr operator ()() Q_DECL_OVERRIDE { const float positionData[] = { -0.8f, -0.8f, 0.0f, @@ -75,7 +75,7 @@ public: vertexBuffer->setData(positionBytes); Qt3D::QMeshDataPtr mesh(new Qt3D::QMeshData(GL_PATCHES)); - mesh->addAttribute(Qt3D::QAbstractMeshData::defaultPositionAttributeName(), + mesh->addAttribute(Qt3D::QMeshData::defaultPositionAttributeName(), Qt3D::AttributePtr(new Qt3D::Attribute(vertexBuffer, GL_FLOAT_VEC3, nVerts))); mesh->setVerticesPerPatch(4); return mesh; diff --git a/examples/tessellation-modes/tessellatedquadmesh.h b/examples/tessellation-modes/tessellatedquadmesh.h index 1161bcfb7..4e137c86f 100644 --- a/examples/tessellation-modes/tessellatedquadmesh.h +++ b/examples/tessellation-modes/tessellatedquadmesh.h @@ -42,7 +42,7 @@ #ifndef TESSELLATEDQUAD_H #define TESSELLATEDQUAD_H -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> class TessellatedQuadMesh : public Qt3D::QAbstractMesh { diff --git a/src/core/core-components/core-components.pri b/src/core/core-components/core-components.pri index ff4be66c1..737c6802e 100644 --- a/src/core/core-components/core-components.pri +++ b/src/core/core-components/core-components.pri @@ -2,13 +2,10 @@ HEADERS += \ $$PWD/qcamera_p.h \ $$PWD/qcamera.h \ $$PWD/qcameralens.h \ - $$PWD/qcameralens_p.h \ - $$PWD/qabstractmesh.h \ - $$PWD/qabstractmesh_p.h + $$PWD/qcameralens_p.h SOURCES += \ $$PWD/qcamera.cpp \ - $$PWD/qcameralens.cpp \ - $$PWD/qabstractmesh.cpp + $$PWD/qcameralens.cpp INCLUDEPATH += $$PWD diff --git a/src/core/io/io.pri b/src/core/io/io.pri index 091a82def..8513810dc 100644 --- a/src/core/io/io.pri +++ b/src/core/io/io.pri @@ -1,14 +1,10 @@ HEADERS += \ - $$PWD/qabstractmeshdata.h \ $$PWD/qabstractbuffer.h \ $$PWD/qabstractattribute.h \ $$PWD/qabstractattribute_p.h \ - $$PWD/qabstractbuffer_p.h \ - $$PWD/qabstractmeshdata_p.h - + $$PWD/qabstractbuffer_p.h SOURCES += \ - $$PWD/qabstractmeshdata.cpp \ $$PWD/qabstractbuffer.cpp \ $$PWD/qabstractattribute.cpp diff --git a/src/core/io/qabstractmeshdata.cpp b/src/core/io/qabstractmeshdata.cpp deleted file mode 100644 index 0e2804837..000000000 --- a/src/core/io/qabstractmeshdata.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qabstractmeshdata.h" -#include "qabstractmeshdata_p.h" -#include "qabstractattribute.h" -#include "qabstractbuffer.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3D { - -QAbstractMeshDataPrivate::QAbstractMeshDataPrivate(QAbstractMeshData *qq) - : q_ptr(qq) - , m_verticesPerPatch(0) -{ -} - -QAbstractMeshData::QAbstractMeshData() - : d_ptr(new QAbstractMeshDataPrivate(this)) -{ -} - -QAbstractMeshData::~QAbstractMeshData() -{ -} - -QAbstractMeshData::QAbstractMeshData(QAbstractMeshDataPrivate &dd) - : d_ptr(&dd) -{ -} - -void QAbstractMeshData::addAttribute(const QString &name, QAbstractAttributePtr attr) -{ - Q_D(QAbstractMeshData); - d->m_attributes[name] = attr; -} - -void QAbstractMeshData::setIndexAttribute(QAbstractAttributePtr attr) -{ - Q_D(QAbstractMeshData); - d->m_indexAttr = attr; -} - -QStringList QAbstractMeshData::attributeNames() const -{ - Q_D(const QAbstractMeshData); - return d->m_attributes.keys(); -} - -QAbstractAttributePtr QAbstractMeshData::attributeByName(QString name) const -{ - Q_D(const QAbstractMeshData); - return d->m_attributes.value(name); -} - -QAbstractAttributePtr QAbstractMeshData::indexAttribute() const -{ - Q_D(const QAbstractMeshData); - return d->m_indexAttr; -} - -void QAbstractMeshData::setVerticesPerPatch(int verticesPerPatch) -{ - Q_D(QAbstractMeshData); - d->m_verticesPerPatch = verticesPerPatch; -} - -int QAbstractMeshData::verticesPerPatch() const -{ - Q_D(const QAbstractMeshData); - return d->m_verticesPerPatch; -} - -int QAbstractMeshData::primitiveCount() const -{ - Q_D(const QAbstractMeshData); - if (d->m_indexAttr) { - return d->m_indexAttr->count(); - } else { - // assume all attribute arrays have the same size - // will break with instanced drawing, but probably per-instance - // arrays aren't coming from this code-path. - // Maybe. - return d->m_attributes.first()->count(); - } -} - -QList<QAbstractBufferPtr> QAbstractMeshData::buffers() const -{ - Q_D(const QAbstractMeshData); - QSet<QAbstractBufferPtr> r; - if (d->m_indexAttr) - r.insert(d->m_indexAttr->buffer()); - - Q_FOREACH (QAbstractAttributePtr v, d->m_attributes.values()) - r.insert(v->buffer()); - - return r.toList(); -} - -void QAbstractMeshData::setBoundingBox(const AxisAlignedBoundingBox &bbox) -{ - Q_D(QAbstractMeshData); - d->m_bbox = bbox; -} - -void QAbstractMeshData::computeBoundsFromAttribute(const QString &name) -{ - Q_D(QAbstractMeshData); - QAbstractAttributePtr attr = attributeByName(name); - if (!attr) { - qWarning() << Q_FUNC_INFO << "unknoen attribute:" << name; - return; - } - d->m_bbox.clear(); - d->m_bbox.update(attr->asVector3D()); -} - -AxisAlignedBoundingBox QAbstractMeshData::boundingBox() const -{ - Q_D(const QAbstractMeshData); - return d->m_bbox; -} - -} // Qt3D - -QT_END_NAMESPACE diff --git a/src/core/io/qabstractmeshdata.h b/src/core/io/qabstractmeshdata.h deleted file mode 100644 index e4cc5352a..000000000 --- a/src/core/io/qabstractmeshdata.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3D_QABSTRACTMESHDATA_H -#define QT3D_QABSTRACTMESHDATA_H - -#include <Qt3DCore/qt3dcore_global.h> -#include <Qt3DCore/axisalignedboundingbox.h> -#include <QSharedPointer> - -QT_BEGIN_NAMESPACE - -namespace Qt3D { - -class QAbstractAttribute; -class QAbstractBuffer; -class QAbstractMeshDataPrivate; - -typedef QSharedPointer<QAbstractAttribute> QAbstractAttributePtr; -typedef QSharedPointer<QAbstractBuffer> QAbstractBufferPtr; - -class QT3DCORESHARED_EXPORT QAbstractMeshData -{ -public: - QAbstractMeshData(); - virtual ~QAbstractMeshData(); - - void addAttribute(const QString& name, QAbstractAttributePtr attr); - void setIndexAttribute(QAbstractAttributePtr attr); - - QStringList attributeNames() const; - QAbstractAttributePtr attributeByName(QString name) const; - QAbstractAttributePtr indexAttribute() const; - - static const QString defaultPositionAttributeName() { return QStringLiteral("vertexPosition"); } - static const QString defaultNormalAttributeName() { return QStringLiteral("vertexNormal"); } - static const QString defaultColorAttributeName() { return QStringLiteral("vertexColor"); } - static const QString defaultTextureCoordinateAttributeName() { return QStringLiteral("vertexTexCoord"); } - static const QString defaultTangentAttributeName() { return QStringLiteral("vertexTangent"); } - - virtual void setPrimitiveType(int primitiveType) = 0; - virtual int primitiveType() const = 0; - - void setVerticesPerPatch(int verticesPerPatch); - int verticesPerPatch() const; - - int primitiveCount() const; - - QList<QAbstractBufferPtr> buffers() const; - - void setBoundingBox(const AxisAlignedBoundingBox &bbox); - void computeBoundsFromAttribute(const QString &name); - - AxisAlignedBoundingBox boundingBox() const; - -protected: - Q_DECLARE_PRIVATE(QAbstractMeshData) - QAbstractMeshDataPrivate *d_ptr; - QAbstractMeshData(QAbstractMeshDataPrivate &dd); -}; - -} // Qt3D - -QT_END_NAMESPACE - -#endif // QT3D_QABSTRACTMESHDATA_H diff --git a/src/core/io/qabstractmeshdata_p.h b/src/core/io/qabstractmeshdata_p.h deleted file mode 100644 index cc2f353b0..000000000 --- a/src/core/io/qabstractmeshdata_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3D_QABSTRACTMESHDATA_P_H -#define QT3D_QABSTRACTMESHDATA_P_H - -#include <Qt3DCore/qt3dcore_global.h> -#include <Qt3DCore/axisalignedboundingbox.h> - -#include <QMap> -#include <QSharedPointer> - -QT_BEGIN_NAMESPACE - -namespace Qt3D { - -class QAbstractMeshData; -class QAbstractAttribute; -class QAbstractBuffer; - -typedef QSharedPointer<QAbstractAttribute> QAbstractAttributePtr; - -class QT3DCORESHARED_EXPORT QAbstractMeshDataPrivate -{ -public: - QAbstractMeshDataPrivate(QAbstractMeshData *qq); - - Q_DECLARE_PUBLIC(QAbstractMeshData) - QAbstractMeshData *q_ptr; - - QMap<QString, QAbstractAttributePtr> m_attributes; - QAbstractAttributePtr m_indexAttr; - AxisAlignedBoundingBox m_bbox; - int m_verticesPerPatch; -}; - -} // Qt3D - -QT_END_NAMESPACE - -#endif // QT3D_QABSTRACTMESHDATA_P_H diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp index 52bc0be0a..68a11337f 100644 --- a/src/plugins/sceneparsers/assimp/assimpparser.cpp +++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp @@ -45,7 +45,7 @@ #include <Qt3DCore/qtransform.h> #include <Qt3DCore/qmatrixtransform.h> #include <Qt3DCore/qcameralens.h> -#include <Qt3DCore/private/qabstractmesh_p.h> +#include <private/qabstractmesh_p.h> #include <Qt3DRenderer/qparameter.h> #include <Qt3DRenderer/qmesh.h> #include <Qt3DRenderer/qmaterial.h> @@ -108,11 +108,11 @@ const QString ASSIMP_MATERIAL_REFLECTIVITY = QStringLiteral("reflectivity"); const QString ASSIMP_MATERIAL_NAME = QStringLiteral("name"); -const QString VERTICES_ATTRIBUTE_NAME = QAbstractMeshData::defaultPositionAttributeName(); -const QString NORMAL_ATTRIBUTE_NAME = QAbstractMeshData::defaultNormalAttributeName(); -const QString TANGENT_ATTRIBUTE_NAME = QAbstractMeshData::defaultTangentAttributeName(); -const QString TEXTCOORD_ATTRIBUTE_NAME = QAbstractMeshData::defaultTextureCoordinateAttributeName(); -const QString COLOR_ATTRIBUTE_NAME = QAbstractMeshData::defaultColorAttributeName(); +const QString VERTICES_ATTRIBUTE_NAME = QMeshData::defaultPositionAttributeName(); +const QString NORMAL_ATTRIBUTE_NAME = QMeshData::defaultNormalAttributeName(); +const QString TANGENT_ATTRIBUTE_NAME = QMeshData::defaultTangentAttributeName(); +const QString TEXTCOORD_ATTRIBUTE_NAME = QMeshData::defaultTextureCoordinateAttributeName(); +const QString COLOR_ATTRIBUTE_NAME = QMeshData::defaultColorAttributeName(); } @@ -197,7 +197,7 @@ private: { public: explicit AssimpMeshFunctor(QMeshDataPtr meshData); - QAbstractMeshDataPtr operator()() Q_DECL_OVERRIDE; + QMeshDataPtr operator()() Q_DECL_OVERRIDE; bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE; private: QMeshDataPtr m_meshData; @@ -842,7 +842,7 @@ AssimpMesh::AssimpMeshFunctor::AssimpMeshFunctor(QMeshDataPtr meshData) { } -QAbstractMeshDataPtr AssimpMesh::AssimpMeshFunctor::operator()() +QMeshDataPtr AssimpMesh::AssimpMeshFunctor::operator()() { return m_meshData; } diff --git a/src/plugins/sceneparsers/assimp/assimpparser_p.h b/src/plugins/sceneparsers/assimp/assimpparser_p.h index 65652408e..ce9d61c9f 100644 --- a/src/plugins/sceneparsers/assimp/assimpparser_p.h +++ b/src/plugins/sceneparsers/assimp/assimpparser_p.h @@ -47,7 +47,7 @@ #include <assimp/scene.h> #include <assimp/postprocess.h> #include <assimp/DefaultLogger.hpp> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <Qt3DRenderer/qmeshdata.h> #include <Qt3DRenderer/private/abstractsceneparser_p.h> #include "assimphelpers_p.h" diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp index cbda8f631..b53aa02fc 100644 --- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp +++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp @@ -48,7 +48,6 @@ #include <Qt3DCore/qmatrixtransform.h> #include <Qt3DCore/qtranslatetransform.h> #include <Qt3DCore/qrotatetransform.h> -#include <Qt3DCore/qabstractmesh.h> #include <Qt3DQuick/quick3dentity.h> #include <Qt3DQuick/quick3dtransform.h> #include <Qt3DQuick/quick3dconfiguration.h> @@ -58,7 +57,6 @@ QT_BEGIN_NAMESPACE void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) { qmlRegisterUncreatableType<Qt3D::QComponent>(uri, 2, 0, "Component", QStringLiteral("")); - qmlRegisterUncreatableType<Qt3D::QAbstractMesh>(uri, 2, 0, "QAbstractMesh", QStringLiteral("")); qmlRegisterUncreatableType<Qt3D::QAbstractTransform>(uri, 2, 0, "QAbstractTransform", QStringLiteral("QAbstractTransform is abstract")); qmlRegisterType<Qt3D::Quick::Quick3DConfiguration>(uri, 2, 0, "Configuration"); diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp index 9c5419e8b..9c3b2464b 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp @@ -42,6 +42,7 @@ #include <QtQml> #include "qt3dquick3drenderplugin.h" +#include <Qt3DRenderer/qabstractmesh.h> #include <Qt3DRenderer/qabstractsceneloader.h> #include <Qt3DRenderer/qsceneloader.h> #include <Qt3DRenderer/qmesh.h> diff --git a/src/render/backend/jobs/loadmeshdatajob.cpp b/src/render/backend/jobs/loadmeshdatajob.cpp index b96566a85..619c6c6ab 100644 --- a/src/render/backend/jobs/loadmeshdatajob.cpp +++ b/src/render/backend/jobs/loadmeshdatajob.cpp @@ -87,7 +87,7 @@ void LoadMeshDataJob::run() QMeshData *meshData = m_renderer->meshDataManager()->data(meshDataHandle); *meshData = *(meshDataPtr.data()); m_renderer->meshDataManager()->addMeshDataForFunctor(meshDataHandle, m_functor); - AttributePtr attr = meshData->attributeByName(QAbstractMeshData::defaultPositionAttributeName()).staticCast<Attribute>(); + AttributePtr attr = meshData->attributeByName(QMeshData::defaultPositionAttributeName()).staticCast<Attribute>(); if (!attr) qCWarning(Jobs) << Q_FUNC_INFO << "unknown attribute: position"; } diff --git a/src/render/backend/jobs/loadmeshdatajob.h b/src/render/backend/jobs/loadmeshdatajob.h index 7012cfaa1..69bbaa936 100644 --- a/src/render/backend/jobs/loadmeshdatajob.h +++ b/src/render/backend/jobs/loadmeshdatajob.h @@ -46,7 +46,7 @@ #include <Qt3DCore/qaspectjob.h> #include <Qt3DCore/qhandle.h> #include <Qt3DRenderer/qmeshdata.h> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <QSharedPointer> QT_BEGIN_NAMESPACE diff --git a/src/render/backend/meshdatamanager_p.h b/src/render/backend/meshdatamanager_p.h index 9d7195bf6..586c2d8e1 100644 --- a/src/render/backend/meshdatamanager_p.h +++ b/src/render/backend/meshdatamanager_p.h @@ -42,7 +42,7 @@ #ifndef QT3D_RENDER_MESHDATAMANAGER_H #define QT3D_RENDER_MESHDATAMANAGER_H -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <Qt3DCore/qresourcesmanager.h> #include <Qt3DRenderer/qmeshdata.h> #include <Qt3DRenderer/private/rendermesh_p.h> diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp index 68a98d98a..c9d859311 100644 --- a/src/render/backend/renderview.cpp +++ b/src/render/backend/renderview.cpp @@ -127,11 +127,11 @@ QStringList RenderView::initializeStandardAttributeNames() { QStringList attributesNames; - attributesNames << QAbstractMeshData::defaultPositionAttributeName(); - attributesNames << QAbstractMeshData::defaultTextureCoordinateAttributeName(); - attributesNames << QAbstractMeshData::defaultNormalAttributeName(); - attributesNames << QAbstractMeshData::defaultColorAttributeName(); - attributesNames << QAbstractMeshData::defaultTangentAttributeName(); + attributesNames << QMeshData::defaultPositionAttributeName(); + attributesNames << QMeshData::defaultTextureCoordinateAttributeName(); + attributesNames << QMeshData::defaultNormalAttributeName(); + attributesNames << QMeshData::defaultColorAttributeName(); + attributesNames << QMeshData::defaultTangentAttributeName(); return attributesNames; } diff --git a/src/core/core-components/qabstractmesh.cpp b/src/render/frontend/qabstractmesh.cpp index 81f811515..81f811515 100644 --- a/src/core/core-components/qabstractmesh.cpp +++ b/src/render/frontend/qabstractmesh.cpp diff --git a/src/core/core-components/qabstractmesh.h b/src/render/frontend/qabstractmesh.h index dde047cc7..ff0ea8ad0 100644 --- a/src/core/core-components/qabstractmesh.h +++ b/src/render/frontend/qabstractmesh.h @@ -42,6 +42,7 @@ #ifndef QT3D_QABSTRACTMESH_H #define QT3D_QABSTRACTMESH_H +#include <Qt3DRenderer/qt3drenderer_global.h> #include <Qt3DCore/qcomponent.h> #include <QSharedPointer> #include <QUuid> @@ -51,21 +52,21 @@ QT_BEGIN_NAMESPACE namespace Qt3D { class QAbstractMeshPrivate; -class QAbstractMeshData; +class QMeshData; -typedef QSharedPointer<QAbstractMeshData> QAbstractMeshDataPtr; +typedef QSharedPointer<QMeshData> QMeshDataPtr; -class QT3DCORESHARED_EXPORT QAbstractMeshFunctor +class QT3DRENDERERSHARED_EXPORT QAbstractMeshFunctor { public: - virtual QAbstractMeshDataPtr operator()() = 0; + virtual QMeshDataPtr operator()() = 0; virtual bool operator ==(const QAbstractMeshFunctor &other) const = 0; virtual ~QAbstractMeshFunctor() {} }; typedef QSharedPointer<QAbstractMeshFunctor> QAbstractMeshFunctorPtr; -class QT3DCORESHARED_EXPORT QAbstractMesh : public QComponent +class QT3DRENDERERSHARED_EXPORT QAbstractMesh : public QComponent { Q_OBJECT diff --git a/src/core/core-components/qabstractmesh_p.h b/src/render/frontend/qabstractmesh_p.h index 8e9b57a24..78e220356 100644 --- a/src/core/core-components/qabstractmesh_p.h +++ b/src/render/frontend/qabstractmesh_p.h @@ -42,7 +42,7 @@ #ifndef QT3D_QABSTRACTMESH_P_H #define QT3D_QABSTRACTMESH_P_H -#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DRenderer/qt3drenderer_global.h> #include <private/qcomponent_p.h> #include <QString> @@ -55,7 +55,7 @@ namespace Qt3D { class QAbstractMesh; -class QT3DCORESHARED_EXPORT QAbstractMeshPrivate : public QComponentPrivate +class QT3DRENDERERSHARED_EXPORT QAbstractMeshPrivate : public QComponentPrivate { public: QAbstractMeshPrivate(QAbstractMesh *qq); diff --git a/src/render/frontend/qcuboidmesh.cpp b/src/render/frontend/qcuboidmesh.cpp index d41448d58..03fefef5a 100644 --- a/src/render/frontend/qcuboidmesh.cpp +++ b/src/render/frontend/qcuboidmesh.cpp @@ -203,7 +203,7 @@ public: { } - QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE + QMeshDataPtr operator ()() Q_DECL_OVERRIDE { return createCuboidMesh(m_xExtent, m_yExtent, m_zExtent, m_yzFaceResolution, @@ -498,24 +498,24 @@ QMeshDataPtr createCuboidMesh(float xExtent, QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES)); quint32 offset = 0; - mesh->addAttribute(QAbstractMeshData::defaultPositionAttributeName(), + mesh->addAttribute(QMeshData::defaultPositionAttributeName(), AttributePtr(new Attribute(vertexBuffer, GL_FLOAT_VEC3, nVerts, offset, stride))); offset += 3 * sizeof(float); - mesh->addAttribute(QAbstractMeshData::defaultTextureCoordinateAttributeName(), + mesh->addAttribute(QMeshData::defaultTextureCoordinateAttributeName(), AttributePtr(new Attribute(vertexBuffer, GL_FLOAT_VEC2, nVerts, offset, stride))); offset += 2 * sizeof(float); - mesh->addAttribute(QAbstractMeshData::defaultNormalAttributeName(), + mesh->addAttribute(QMeshData::defaultNormalAttributeName(), AttributePtr(new Attribute(vertexBuffer, GL_FLOAT_VEC3, nVerts, offset, stride))); offset += 3 * sizeof(float); - mesh->addAttribute(QAbstractMeshData::defaultTangentAttributeName(), + mesh->addAttribute(QMeshData::defaultTangentAttributeName(), AttributePtr(new Attribute(vertexBuffer, GL_FLOAT_VEC4, nVerts, offset, stride))); mesh->setIndexAttribute(AttributePtr(new Attribute(indexBuffer, GL_UNSIGNED_SHORT, indexCount, 0, 0))); - mesh->computeBoundsFromAttribute(QAbstractMeshData::defaultPositionAttributeName()); + mesh->computeBoundsFromAttribute(QMeshData::defaultPositionAttributeName()); qCDebug(Render::Frontend) << "computed axis-aligned bounding box is:" << mesh->boundingBox(); return mesh; diff --git a/src/render/frontend/qcuboidmesh.h b/src/render/frontend/qcuboidmesh.h index f38cfe116..ae4189c68 100644 --- a/src/render/frontend/qcuboidmesh.h +++ b/src/render/frontend/qcuboidmesh.h @@ -43,7 +43,7 @@ #define QT3D_CUBOIDMESH_H #include <Qt3DRenderer/qt3drenderer_global.h> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <QSize> QT_BEGIN_NAMESPACE diff --git a/src/render/frontend/qcuboidmesh_p.h b/src/render/frontend/qcuboidmesh_p.h index 968515c7b..c44a4215d 100644 --- a/src/render/frontend/qcuboidmesh_p.h +++ b/src/render/frontend/qcuboidmesh_p.h @@ -42,7 +42,7 @@ #ifndef QCUBOIDMESH_P_H #define QCUBOIDMESH_P_H -#include <Qt3DCore/private/qabstractmesh_p.h> +#include <Qt3DRenderer/private/qabstractmesh_p.h> #include <QtCore/qsize.h> diff --git a/src/render/frontend/qcylindermesh.cpp b/src/render/frontend/qcylindermesh.cpp index 9fd1ce71a..dc5240a3e 100644 --- a/src/render/frontend/qcylindermesh.cpp +++ b/src/render/frontend/qcylindermesh.cpp @@ -48,7 +48,7 @@ #include "qbuffer.h" #include "qattribute.h" #include "qmeshdata.h" -#include <Qt3DCore/private/qabstractmesh_p.h> +#include <Qt3DRenderer/private/qabstractmesh_p.h> #include <cmath> @@ -60,7 +60,7 @@ class CylinderMeshFunctor : public QAbstractMeshFunctor { public: CylinderMeshFunctor(int rings, int slices, float radius, float length); - QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE; + QMeshDataPtr operator ()() Q_DECL_OVERRIDE; bool operator ==(const QAbstractMeshFunctor &other) const; private: @@ -169,26 +169,26 @@ float QCylinderMesh::length() const return d->m_length; } -QAbstractMeshDataPtr assembleMesh(const QByteArray &verticesBytes, quint32 vertexSize, int verticesCount, +QMeshDataPtr assembleMesh(const QByteArray &verticesBytes, quint32 vertexSize, int verticesCount, const QByteArray &indicesBytes, int indicesCount) { - QAbstractMeshDataPtr mesh(new QMeshData(GL_TRIANGLES)); + QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES)); BufferPtr verticesBuffer(new Buffer(QOpenGLBuffer::VertexBuffer)); verticesBuffer->setUsage(QOpenGLBuffer::StaticDraw); verticesBuffer->setData(verticesBytes); - mesh->addAttribute(QAbstractMeshData::defaultPositionAttributeName(), + mesh->addAttribute(QMeshData::defaultPositionAttributeName(), QAbstractAttributePtr(new Attribute(verticesBuffer, GL_FLOAT_VEC3, verticesCount, 0, vertexSize))); quint32 offset = sizeof(float) * 3; - mesh->addAttribute(QAbstractMeshData::defaultTextureCoordinateAttributeName(), + mesh->addAttribute(QMeshData::defaultTextureCoordinateAttributeName(), QAbstractAttributePtr(new Attribute(verticesBuffer, GL_FLOAT_VEC2, verticesCount, offset, vertexSize))); offset += sizeof(float) * 2; - mesh->addAttribute(QAbstractMeshData::defaultNormalAttributeName(), + mesh->addAttribute(QMeshData::defaultNormalAttributeName(), QAbstractAttributePtr(new Attribute(verticesBuffer, GL_FLOAT_VEC3, verticesCount, offset, vertexSize))); offset += sizeof(float) * 3; @@ -198,7 +198,7 @@ QAbstractMeshDataPtr assembleMesh(const QByteArray &verticesBytes, quint32 verte indicesBuffer->setData(indicesBytes); mesh->setIndexAttribute(AttributePtr(new Attribute(indicesBuffer, GL_UNSIGNED_SHORT, indicesCount, 0, 0))); - mesh->computeBoundsFromAttribute(QAbstractMeshData::defaultPositionAttributeName()); + mesh->computeBoundsFromAttribute(QMeshData::defaultPositionAttributeName()); return mesh; } @@ -297,7 +297,7 @@ void createDisc(float *&verticesPtr, quint16 *&indicesPtr, } } -QAbstractMeshDataPtr createCylinderMesh(double radius, double length, +QMeshDataPtr createCylinderMesh(double radius, double length, int rings, int slices) { const int verticesCount = (slices + 1) * rings + 2 * (slices + 1) + 2; @@ -342,7 +342,7 @@ CylinderMeshFunctor::CylinderMeshFunctor(int rings, int slices, float radius, fl { } -QAbstractMeshDataPtr CylinderMeshFunctor::operator ()() +QMeshDataPtr CylinderMeshFunctor::operator ()() { return createCylinderMesh(m_radius, m_length, m_rings, m_slices); } diff --git a/src/render/frontend/qcylindermesh.h b/src/render/frontend/qcylindermesh.h index 05bf3ac81..57d9c2fec 100644 --- a/src/render/frontend/qcylindermesh.h +++ b/src/render/frontend/qcylindermesh.h @@ -43,7 +43,7 @@ #define QT3D_QCYLINDERMESH_H #include <Qt3DRenderer/qt3drenderer_global.h> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> QT_BEGIN_NAMESPACE diff --git a/src/render/frontend/qmesh.cpp b/src/render/frontend/qmesh.cpp index e4e5b54d8..d48a70089 100644 --- a/src/render/frontend/qmesh.cpp +++ b/src/render/frontend/qmesh.cpp @@ -59,7 +59,7 @@ class MeshFunctor : public QAbstractMeshFunctor { public : MeshFunctor(const QString &sourcePath); - QAbstractMeshDataPtr operator()() Q_DECL_OVERRIDE; + QMeshDataPtr operator()() Q_DECL_OVERRIDE; bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE; private: @@ -117,7 +117,7 @@ MeshFunctor::MeshFunctor(const QString &sourcePath) { } -QAbstractMeshDataPtr MeshFunctor::operator()() +QMeshDataPtr MeshFunctor::operator()() { if (m_sourcePath.isEmpty()) { qCWarning(Render::Jobs) << Q_FUNC_INFO << "Mesh is empty, nothing to load"; diff --git a/src/render/frontend/qmesh.h b/src/render/frontend/qmesh.h index d69bb360d..3aa8d43d6 100644 --- a/src/render/frontend/qmesh.h +++ b/src/render/frontend/qmesh.h @@ -42,7 +42,7 @@ #ifndef QT3D_QMESH_H #define QT3D_QMESH_H -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <Qt3DRenderer/qt3drenderer_global.h> #include <Qt3DRenderer/qmeshdata.h> @@ -51,9 +51,9 @@ QT_BEGIN_NAMESPACE namespace Qt3D { class QMeshPrivate; -class QAbstractMeshData; +class QMeshData; -typedef QSharedPointer<QAbstractMeshData> QAbstractMeshDataPtr; +typedef QSharedPointer<QMeshData> QMeshDataPtr; /** * @brief Simple static mesh * diff --git a/src/render/frontend/qplanemesh.cpp b/src/render/frontend/qplanemesh.cpp index 69aa69ab0..ad473421f 100644 --- a/src/render/frontend/qplanemesh.cpp +++ b/src/render/frontend/qplanemesh.cpp @@ -141,7 +141,7 @@ public: { } - QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE + QMeshDataPtr operator ()() Q_DECL_OVERRIDE { return createPlaneMesh(m_width, m_height, m_meshResolution); } @@ -226,19 +226,19 @@ QMeshDataPtr createPlaneMesh(float w, float h, const QSize &resolution) // Create the mesh data, specify the vertex format and data QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES)); quint32 offset = 0; - mesh->addAttribute(QAbstractMeshData::defaultPositionAttributeName(), + mesh->addAttribute(QMeshData::defaultPositionAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride))); offset += 3 * sizeof(float); - mesh->addAttribute(QAbstractMeshData::defaultTextureCoordinateAttributeName(), + mesh->addAttribute(QMeshData::defaultTextureCoordinateAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC2, nVerts, offset, stride))); offset += 2 * sizeof(float); - mesh->addAttribute(QAbstractMeshData::defaultNormalAttributeName(), + mesh->addAttribute(QMeshData::defaultNormalAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride))); offset += 3 * sizeof(float); - mesh->addAttribute(QAbstractMeshData::defaultTangentAttributeName(), + mesh->addAttribute(QMeshData::defaultTangentAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC4, nVerts, offset, stride))); // Create the index data. 2 triangles per rectangular face @@ -275,7 +275,7 @@ QMeshDataPtr createPlaneMesh(float w, float h, const QSize &resolution) // Specify index data on the mesh mesh->setIndexAttribute(AttributePtr(new Attribute(indexBuffer, GL_UNSIGNED_SHORT, indices, 0, 0))); - mesh->computeBoundsFromAttribute(QAbstractMeshData::defaultPositionAttributeName()); + mesh->computeBoundsFromAttribute(QMeshData::defaultPositionAttributeName()); qCDebug(Render::Frontend) << "computed axis-aligned bounding box is:" << mesh->boundingBox(); return mesh; diff --git a/src/render/frontend/qplanemesh.h b/src/render/frontend/qplanemesh.h index f3e49d0e8..5e83a1286 100644 --- a/src/render/frontend/qplanemesh.h +++ b/src/render/frontend/qplanemesh.h @@ -43,7 +43,7 @@ #define QT3D_QPLANEMESH_H #include <Qt3DRenderer/qt3drenderer_global.h> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <QSize> QT_BEGIN_NAMESPACE diff --git a/src/render/frontend/qplanemesh_p.h b/src/render/frontend/qplanemesh_p.h index 421bb1edd..42ce2e8e7 100644 --- a/src/render/frontend/qplanemesh_p.h +++ b/src/render/frontend/qplanemesh_p.h @@ -39,11 +39,10 @@ ** ****************************************************************************/ -#ifndef QPLANEMESH_P_H -#define QPLANEMESH_P_H - -#include <Qt3DCore/private/qabstractmesh_p.h> +#ifndef QT3D_QPLANEMESH_P_H +#define QT3D_QPLANEMESH_P_H +#include <private/qabstractmesh_p.h> #include <QtCore/qsize.h> QT_BEGIN_NAMESPACE @@ -68,4 +67,4 @@ public: QT_END_NAMESPACE -#endif // QPLANEMESH_P_H +#endif // QT3D_QPLANEMESH_P_H diff --git a/src/render/frontend/qspheremesh.cpp b/src/render/frontend/qspheremesh.cpp index 4cf35c2b1..bb0a3f9ce 100644 --- a/src/render/frontend/qspheremesh.cpp +++ b/src/render/frontend/qspheremesh.cpp @@ -61,7 +61,7 @@ class SphereMeshFunctor : public QAbstractMeshFunctor { public: SphereMeshFunctor(int rings, int slices, float radius, bool generateTangents); - QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE; + QMeshDataPtr operator ()() Q_DECL_OVERRIDE; bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE; private: @@ -232,17 +232,17 @@ QMeshDataPtr createSphereMesh(double radius, int rings, int slices, bool hasTang buf->setUsage(QOpenGLBuffer::StaticDraw); buf->setData(bufferBytes); - mesh->addAttribute(QAbstractMeshData::defaultPositionAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, 0, stride))); + mesh->addAttribute(QMeshData::defaultPositionAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, 0, stride))); quint32 offset = sizeof(float) * 3; - mesh->addAttribute(QAbstractMeshData::defaultTextureCoordinateAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC2, nVerts, offset, stride))); + mesh->addAttribute(QMeshData::defaultTextureCoordinateAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC2, nVerts, offset, stride))); offset += sizeof(float) * 2; - mesh->addAttribute(QAbstractMeshData::defaultNormalAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride))); + mesh->addAttribute(QMeshData::defaultNormalAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride))); offset += sizeof(float) * 3; if (hasTangents) { - mesh->addAttribute(QAbstractMeshData::defaultTangentAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC4, nVerts, offset, stride))); + mesh->addAttribute(QMeshData::defaultTangentAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC4, nVerts, offset, stride))); offset += sizeof(float) * 4; } @@ -300,7 +300,7 @@ QMeshDataPtr createSphereMesh(double radius, int rings, int slices, bool hasTang indexBuffer->setData(indexBytes); mesh->setIndexAttribute(AttributePtr(new Attribute(indexBuffer, GL_UNSIGNED_SHORT, indices, 0, 0))); - mesh->computeBoundsFromAttribute(QAbstractMeshData::defaultPositionAttributeName()); + mesh->computeBoundsFromAttribute(QMeshData::defaultPositionAttributeName()); qCDebug(Render::Frontend) << "computed sphere bounds is:" << mesh->boundingBox(); return mesh; @@ -315,7 +315,7 @@ SphereMeshFunctor::SphereMeshFunctor(int rings, int slices, float radius, bool g { } -QAbstractMeshDataPtr SphereMeshFunctor::operator ()() +QMeshDataPtr SphereMeshFunctor::operator ()() { return createSphereMesh(m_radius, m_rings, m_slices, m_generateTangents); } diff --git a/src/render/frontend/qspheremesh.h b/src/render/frontend/qspheremesh.h index 2b0115b5c..812b795f8 100644 --- a/src/render/frontend/qspheremesh.h +++ b/src/render/frontend/qspheremesh.h @@ -43,7 +43,7 @@ #define QT3D_QSPHEREMESH_H #include <Qt3DRenderer/qt3drenderer_global.h> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> QT_BEGIN_NAMESPACE diff --git a/src/render/frontend/qtorusmesh.cpp b/src/render/frontend/qtorusmesh.cpp index 341c58054..a8bc9b624 100644 --- a/src/render/frontend/qtorusmesh.cpp +++ b/src/render/frontend/qtorusmesh.cpp @@ -48,7 +48,7 @@ #include "qbuffer.h" #include "qattribute.h" #include "qmeshdata.h" -#include <Qt3DCore/private/qabstractmesh_p.h> +#include <Qt3DRenderer/private/qabstractmesh_p.h> #include <cmath> @@ -60,7 +60,7 @@ class TorusMeshFunctor : public QAbstractMeshFunctor { public: TorusMeshFunctor(int rings, int slices, float radius, float minorRadius); - QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE; + QMeshDataPtr operator ()() Q_DECL_OVERRIDE; bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE; private: @@ -167,10 +167,10 @@ float QTorusMesh::minorRadius() const return d->m_minorRadius; } -QAbstractMeshDataPtr createTorusMesh(double radius, double minorRadius, +QMeshDataPtr createTorusMesh(double radius, double minorRadius, int rings, int sides) { - QAbstractMeshDataPtr mesh(new QMeshData(GL_TRIANGLES)); + QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES)); int nVerts = sides * ( rings + 1 ); QByteArray bufferBytes; @@ -217,13 +217,13 @@ QAbstractMeshDataPtr createTorusMesh(double radius, double minorRadius, buf->setUsage(QOpenGLBuffer::StaticDraw); buf->setData(bufferBytes); - mesh->addAttribute(QAbstractMeshData::defaultPositionAttributeName(), QAbstractAttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, 0, stride))); + mesh->addAttribute(QMeshData::defaultPositionAttributeName(), QAbstractAttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, 0, stride))); quint32 offset = sizeof(float) * 3; - mesh->addAttribute(QAbstractMeshData::defaultTextureCoordinateAttributeName(), QAbstractAttributePtr(new Attribute(buf, GL_FLOAT_VEC2, nVerts, offset, stride))); + mesh->addAttribute(QMeshData::defaultTextureCoordinateAttributeName(), QAbstractAttributePtr(new Attribute(buf, GL_FLOAT_VEC2, nVerts, offset, stride))); offset += sizeof(float) * 2; - mesh->addAttribute(QAbstractMeshData::defaultNormalAttributeName(), QAbstractAttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride))); + mesh->addAttribute(QMeshData::defaultNormalAttributeName(), QAbstractAttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride))); offset += sizeof(float) * 3; QByteArray indexBytes; @@ -254,7 +254,7 @@ QAbstractMeshDataPtr createTorusMesh(double radius, double minorRadius, indexBuffer->setData(indexBytes); mesh->setIndexAttribute(AttributePtr(new Attribute(indexBuffer, GL_UNSIGNED_SHORT, indices, 0, 0))); - mesh->computeBoundsFromAttribute(QAbstractMeshData::defaultPositionAttributeName()); + mesh->computeBoundsFromAttribute(QMeshData::defaultPositionAttributeName()); return mesh; } @@ -274,7 +274,7 @@ TorusMeshFunctor::TorusMeshFunctor(int rings, int slices, float radius, float mi { } -QAbstractMeshDataPtr TorusMeshFunctor::operator ()() +QMeshDataPtr TorusMeshFunctor::operator ()() { return createTorusMesh(m_radius, m_minorRadius, m_rings, m_slices); } diff --git a/src/render/frontend/qtorusmesh.h b/src/render/frontend/qtorusmesh.h index dec92a9aa..f492076c2 100644 --- a/src/render/frontend/qtorusmesh.h +++ b/src/render/frontend/qtorusmesh.h @@ -43,7 +43,7 @@ #define QT3D_QTORUSMESH_H #include <Qt3DRenderer/qt3drenderer_global.h> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> QT_BEGIN_NAMESPACE diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri index 9eeab15c0..7f2efe0f3 100644 --- a/src/render/frontend/render-frontend.pri +++ b/src/render/frontend/render-frontend.pri @@ -61,7 +61,9 @@ HEADERS += \ $$PWD/qrenderstate_p.h \ $$PWD/qalphacoverage.h \ $$PWD/qannotation.h \ - $$PWD/qannotation_p.h + $$PWD/qannotation_p.h \ + $$PWD/qabstractmesh_p.h \ + $$PWD/qabstractmesh.h SOURCES += \ $$PWD/qmaterial.cpp \ @@ -102,4 +104,5 @@ SOURCES += \ $$PWD/qrenderattachment.cpp \ $$PWD/qrendertarget.cpp \ $$PWD/qalphacoverage.cpp \ - $$PWD/qannotation.cpp + $$PWD/qannotation.cpp \ + $$PWD/qabstractmesh.cpp diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp index c78e844e7..f41a5ed23 100644 --- a/src/render/io/gltfparser.cpp +++ b/src/render/io/gltfparser.cpp @@ -74,7 +74,7 @@ // need to move these to somewhere common? #include <Qt3DRenderer/private/renderstate_p.h> #include <Qt3DRenderer/private/blendstate_p.h> -#include <Qt3DCore/private/qabstractmesh_p.h> +#include <private/qabstractmesh_p.h> QT_BEGIN_NAMESPACE @@ -215,7 +215,7 @@ private: { public: explicit GLTFParserMeshFunctor(QMeshDataPtr meshData); - QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE; + QMeshDataPtr operator ()() Q_DECL_OVERRIDE; bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE; private: @@ -1041,7 +1041,7 @@ GLTFParserMesh::GLTFParserMeshFunctor::GLTFParserMeshFunctor(QMeshDataPtr meshDa { } -QAbstractMeshDataPtr GLTFParserMesh::GLTFParserMeshFunctor::operator ()() +QMeshDataPtr GLTFParserMesh::GLTFParserMeshFunctor::operator ()() { return m_meshData; } diff --git a/src/render/io/gltfparser_p.h b/src/render/io/gltfparser_p.h index ffbb18930..10d8bfab7 100644 --- a/src/render/io/gltfparser_p.h +++ b/src/render/io/gltfparser_p.h @@ -50,7 +50,7 @@ #include <Qt3DRenderer/qbuffer.h> #include <QJsonDocument> #include <QMultiHash> -#include <Qt3DCore/qabstractmesh.h> +#include <Qt3DRenderer/qabstractmesh.h> #include <QImage> #include <Qt3DRenderer/private/abstractsceneparser_p.h> diff --git a/src/render/io/objloader.cpp b/src/render/io/objloader.cpp index 9956bb9af..4afadfae3 100644 --- a/src/render/io/objloader.cpp +++ b/src/render/io/objloader.cpp @@ -254,21 +254,21 @@ QMeshData *ObjLoader::mesh() const buf->setData(bufferBytes); - mesh->addAttribute(QAbstractMeshData::defaultPositionAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, count, 0, stride))); + mesh->addAttribute(QMeshData::defaultPositionAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, count, 0, stride))); quint32 offset = sizeof(float) * 3; if (hasTextureCoordinates()) { - mesh->addAttribute(QAbstractMeshData::defaultTextureCoordinateAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC2, count, offset, stride))); + mesh->addAttribute(QMeshData::defaultTextureCoordinateAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC2, count, offset, stride))); offset += sizeof(float) * 2; } if (hasNormals()) { - mesh->addAttribute(QAbstractMeshData::defaultNormalAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, count, offset, stride))); + mesh->addAttribute(QMeshData::defaultNormalAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, count, offset, stride))); offset += sizeof(float) * 3; } if (hasTangents()) { - mesh->addAttribute(QAbstractMeshData::defaultTangentAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC4, count, offset, stride))); + mesh->addAttribute(QMeshData::defaultTangentAttributeName(), AttributePtr(new Attribute(buf, GL_FLOAT_VEC4, count, offset, stride))); offset += sizeof(float) * 4; } @@ -294,7 +294,7 @@ QMeshData *ObjLoader::mesh() const indexBuffer->setData(indexBytes); mesh->setIndexAttribute(AttributePtr(new Attribute(indexBuffer, ty, m_indices.size(), 0, 0))); - mesh->computeBoundsFromAttribute(QAbstractMeshData::defaultPositionAttributeName()); + mesh->computeBoundsFromAttribute(QMeshData::defaultPositionAttributeName()); qCDebug(Render::Io) << "computed bounds is:" << mesh->boundingBox(); return mesh; diff --git a/src/render/io/qmeshdata.cpp b/src/render/io/qmeshdata.cpp index 00c7c3a05..3cc848c64 100644 --- a/src/render/io/qmeshdata.cpp +++ b/src/render/io/qmeshdata.cpp @@ -41,9 +41,8 @@ #include "qmeshdata.h" #include "qmeshdata_p.h" - -#include <QSet> -#include "renderlogging.h" +#include <Qt3DCore/qabstractattribute.h> +#include <Qt3DCore/qabstractbuffer.h> #include <QOpenGLVertexArrayObject> QT_BEGIN_NAMESPACE @@ -51,25 +50,118 @@ QT_BEGIN_NAMESPACE namespace Qt3D { QMeshDataPrivate::QMeshDataPrivate(QMeshData *qq) - : QAbstractMeshDataPrivate(qq) + : q_ptr(qq) + , m_verticesPerPatch(0) , m_primitiveType(0) { } -QMeshData::QMeshData() - : QAbstractMeshData(*new QMeshDataPrivate(this)) +QMeshData::QMeshData(int primitiveType) + : d_ptr(new QMeshDataPrivate(this)) +{ + setPrimitiveType(primitiveType); +} + +QMeshData::~QMeshData() { } QMeshData::QMeshData(QMeshDataPrivate &dd) - : QAbstractMeshData(dd) + : d_ptr(&dd) { } -QMeshData::QMeshData(int primitiveType) - : QAbstractMeshData(*new QMeshDataPrivate(this)) +void QMeshData::addAttribute(const QString &name, QAbstractAttributePtr attr) { - setPrimitiveType(primitiveType); + Q_D(QMeshData); + d->m_attributes.insert(name, attr); +} + +void QMeshData::setIndexAttribute(QAbstractAttributePtr attr) +{ + Q_D(QMeshData); + d->m_indexAttr = attr; +} + +QStringList QMeshData::attributeNames() const +{ + Q_D(const QMeshData); + return d->m_attributes.keys(); +} + +QAbstractAttributePtr QMeshData::attributeByName(QString name) const +{ + Q_D(const QMeshData); + return d->m_attributes.value(name); +} + +QAbstractAttributePtr QMeshData::indexAttribute() const +{ + Q_D(const QMeshData); + return d->m_indexAttr; +} + +void QMeshData::setVerticesPerPatch(int verticesPerPatch) +{ + Q_D(QMeshData); + d->m_verticesPerPatch = verticesPerPatch; +} + +int QMeshData::verticesPerPatch() const +{ + Q_D(const QMeshData); + return d->m_verticesPerPatch; +} + +int QMeshData::primitiveCount() const +{ + Q_D(const QMeshData); + if (d->m_indexAttr) { + return d->m_indexAttr->count(); + } else { + // assume all attribute arrays have the same size + // will break with instanced drawing, but probably per-instance + // arrays aren't coming from this code-path. + // Maybe. + return d->m_attributes.first()->count(); + } +} + +QList<QAbstractBufferPtr> QMeshData::buffers() const +{ + Q_D(const QMeshData); + QSet<QAbstractBufferPtr> r; + if (d->m_indexAttr) + r.insert(d->m_indexAttr->buffer()); + + Q_FOREACH (QAbstractAttributePtr v, d->m_attributes.values()) + r.insert(v->buffer()); + + return r.toList(); +} + +void QMeshData::setBoundingBox(const AxisAlignedBoundingBox &bbox) +{ + Q_D(QMeshData); + d->m_bbox = bbox; +} + +void QMeshData::computeBoundsFromAttribute(const QString &name) +{ + Q_D(QMeshData); + QAbstractAttributePtr attr = attributeByName(name); + if (!attr) { + qWarning() << Q_FUNC_INFO << "unknoen attribute:" << name; + return; + } + d->m_bbox.clear(); + d->m_bbox.update(attr->asVector3D()); +} + +AxisAlignedBoundingBox QMeshData::boundingBox() const +{ + Q_D(const QMeshData); + return d->m_bbox; } void QMeshData::setPrimitiveType(int primitiveType) @@ -88,6 +180,6 @@ int QMeshData::primitiveType() const return d->m_primitiveType; } -} // of namespace +} // Qt3D QT_END_NAMESPACE diff --git a/src/render/io/qmeshdata.h b/src/render/io/qmeshdata.h index 043ff7ba1..0165c3ac3 100644 --- a/src/render/io/qmeshdata.h +++ b/src/render/io/qmeshdata.h @@ -42,39 +42,64 @@ #ifndef QT3D_QMESHDATA_H #define QT3D_QMESHDATA_H -#include <QSharedPointer> -#include <Qt3DCore/qabstractmeshdata.h> #include <Qt3DRenderer/qt3drenderer_global.h> +#include <Qt3DCore/axisalignedboundingbox.h> +#include <QSharedPointer> QT_BEGIN_NAMESPACE namespace Qt3D { -/** - * @brief The QMeshData class is shared by all instances of a RenderMesh, - * and holds the actual client (CPU)-side buffers representing mesh attributes - * and indices. - */ - +class QAbstractAttribute; +class QAbstractBuffer; class QMeshDataPrivate; -class QT3DRENDERERSHARED_EXPORT QMeshData : public QAbstractMeshData +typedef QSharedPointer<QAbstractAttribute> QAbstractAttributePtr; +typedef QSharedPointer<QAbstractBuffer> QAbstractBufferPtr; + +class QT3DRENDERERSHARED_EXPORT QMeshData { public: - QMeshData(); - explicit QMeshData(int primitiveType); + explicit QMeshData(int primitiveType = 0); + virtual ~QMeshData(); + + void addAttribute(const QString& name, QAbstractAttributePtr attr); + void setIndexAttribute(QAbstractAttributePtr attr); + + QStringList attributeNames() const; + QAbstractAttributePtr attributeByName(QString name) const; + QAbstractAttributePtr indexAttribute() const; + + static const QString defaultPositionAttributeName() { return QStringLiteral("vertexPosition"); } + static const QString defaultNormalAttributeName() { return QStringLiteral("vertexNormal"); } + static const QString defaultColorAttributeName() { return QStringLiteral("vertexColor"); } + static const QString defaultTextureCoordinateAttributeName() { return QStringLiteral("vertexTexCoord"); } + static const QString defaultTangentAttributeName() { return QStringLiteral("vertexTangent"); } + + void setPrimitiveType(int primitiveType); + int primitiveType() const; + + void setVerticesPerPatch(int verticesPerPatch); + int verticesPerPatch() const; + + int primitiveCount() const; + + QList<QAbstractBufferPtr> buffers() const; + + void setBoundingBox(const AxisAlignedBoundingBox &bbox); + void computeBoundsFromAttribute(const QString &name); - void setPrimitiveType(int primitiveType) Q_DECL_OVERRIDE; - int primitiveType() const Q_DECL_OVERRIDE; + AxisAlignedBoundingBox boundingBox() const; protected: Q_DECLARE_PRIVATE(QMeshData) + QMeshDataPrivate *d_ptr; QMeshData(QMeshDataPrivate &dd); }; typedef QSharedPointer<QMeshData> QMeshDataPtr; -} +} // Qt3D QT_END_NAMESPACE diff --git a/src/render/io/qmeshdata_p.h b/src/render/io/qmeshdata_p.h index 9776e2719..774626754 100644 --- a/src/render/io/qmeshdata_p.h +++ b/src/render/io/qmeshdata_p.h @@ -42,20 +42,34 @@ #ifndef QT3D_QMESHDATA_P_H #define QT3D_QMESHDATA_P_H -#include <private/qabstractmeshdata_p.h> -#include <Qt3DRenderer/qt3drenderer_global.h> -#include <Qt3DRenderer/qmeshdata.h> +#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DCore/axisalignedboundingbox.h> + +#include <QMap> +#include <QSharedPointer> QT_BEGIN_NAMESPACE namespace Qt3D { -class QT3DRENDERERSHARED_EXPORT QMeshDataPrivate : public QAbstractMeshDataPrivate +class QMeshData; +class QAbstractAttribute; +class QAbstractBuffer; + +typedef QSharedPointer<QAbstractAttribute> QAbstractAttributePtr; + +class QT3DCORESHARED_EXPORT QMeshDataPrivate { public: QMeshDataPrivate(QMeshData *qq); Q_DECLARE_PUBLIC(QMeshData) + QMeshData *q_ptr; + + QMap<QString, QAbstractAttributePtr> m_attributes; + QAbstractAttributePtr m_indexAttr; + AxisAlignedBoundingBox m_bbox; + int m_verticesPerPatch; int m_primitiveType; }; diff --git a/src/render/io/render-io.pri b/src/render/io/render-io.pri index 5f8e6df09..f4fa77de5 100644 --- a/src/render/io/render-io.pri +++ b/src/render/io/render-io.pri @@ -1,7 +1,6 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qmeshdata.h \ $$PWD/gltfparser_p.h \ $$PWD/objloader_p.h \ $$PWD/texturedata.h \ @@ -10,13 +9,14 @@ HEADERS += \ $$PWD/qattribute_p.h \ $$PWD/qbuffer.h \ $$PWD/qbuffer_p.h \ - $$PWD/qmeshdata_p.h + $$PWD/qmeshdata_p.h \ + $$PWD/qmeshdata.h SOURCES += \ - $$PWD/qmeshdata.cpp \ $$PWD/gltfparser.cpp \ $$PWD/objloader.cpp \ $$PWD/texturedata.cpp \ $$PWD/abstractsceneparser.cpp \ $$PWD/qattribute.cpp \ - $$PWD/qbuffer.cpp + $$PWD/qbuffer.cpp \ + $$PWD/qmeshdata.cpp |