summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/geometry/geometry.pri6
-rw-r--r--src/core/geometry/qgeometryview.cpp458
-rw-r--r--src/core/geometry/qgeometryview.h146
-rw-r--r--src/core/geometry/qgeometryview_p.h91
-rw-r--r--src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp2
-rw-r--r--src/render/geometry/geometryrenderer.cpp89
-rw-r--r--src/render/geometry/qgeometryrenderer.cpp42
-rw-r--r--src/render/geometry/qgeometryrenderer.h12
-rw-r--r--src/render/geometry/qgeometryrenderer_p.h1
9 files changed, 799 insertions, 48 deletions
diff --git a/src/core/geometry/geometry.pri b/src/core/geometry/geometry.pri
index 13756ccb3..3425be857 100644
--- a/src/core/geometry/geometry.pri
+++ b/src/core/geometry/geometry.pri
@@ -8,10 +8,14 @@ HEADERS += \
$$PWD/qbuffer_p.h \
$$PWD/qgeometry_p.h \
$$PWD/qgeometry.h \
- $$PWD/qgeometryfactory_p.h
+ $$PWD/qgeometryfactory_p.h \
+ $$PWD/qgeometryview_p.h \
+ $$PWD/qgeometryview.h
SOURCES += \
$$PWD/qabstractfunctor.cpp \
$$PWD/qattribute.cpp \
$$PWD/qbuffer.cpp \
$$PWD/qgeometry.cpp \
+ $$PWD/qgeometryview.cpp
+
diff --git a/src/core/geometry/qgeometryview.cpp b/src/core/geometry/qgeometryview.cpp
new file mode 100644
index 000000000..991bca0de
--- /dev/null
+++ b/src/core/geometry/qgeometryview.cpp
@@ -0,0 +1,458 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "qgeometryview.h"
+#include "qgeometryview_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+QGeometryViewPrivate::QGeometryViewPrivate()
+ : QNodePrivate()
+ , m_instanceCount(1)
+ , m_vertexCount(0)
+ , m_indexOffset(0)
+ , m_firstInstance(0)
+ , m_firstVertex(0)
+ , m_indexBufferByteOffset(0)
+ , m_restartIndexValue(-1)
+ , m_verticesPerPatch(0)
+ , m_primitiveRestart(false)
+ , m_geometry(nullptr)
+ , m_primitiveType(QGeometryView::Triangles)
+{
+}
+
+QGeometryViewPrivate::~QGeometryViewPrivate()
+{
+}
+
+/*!
+ \qmltype GeometryView
+ \instantiates Qt3DCore::QGeometryView
+ \inqmlmodule Qt3D.Core
+ \inherits Node
+ \since 6.0
+ \brief Encapsulates geometry details.
+
+ A GeometryView holds all the information necessary to handle
+ a Geometry. A Geometry holds the coordinates of the geometry data -
+ GeometryView specifies how to interpret that data.
+ */
+
+/*!
+ \class Qt3DCore::QGeometryView
+ \inmodule Qt3DCore
+ \since 6.0
+ \brief Encapsulates geometry details.
+
+ A GeometryView holds all the information necessary to handle
+ a Geometry. A Geometry holds the coordinates of the geometry data -
+ GeometryView specifies how to interpret that data.
+ */
+
+
+/*!
+ \enum QGeometryView::PrimitiveType
+
+ The type of the primitive.
+
+ \value Points List of points
+ \value Lines List of lines
+ \value LineLoop Connected group of lines connected at ends forming a loop
+ \value LineStrip Connected group of lines
+ \value Triangles List of triangles
+ \value TriangleStrip List of connected triangles
+ \value TriangleFan List of connected triagles where all triangles share the first vertex
+ \value LinesAdjacency Allows geometry shader to access adjacent lines in a line list
+ \value TrianglesAdjacency Allows geometry shader to access adjacent triangles in a triangle list
+ \value LineStripAdjacency Allows geometry shader to access adjacent lines in a line strip
+ \value TriangleStripAdjacency Allows geometry shader to access adjacent triangles in a triangle strip
+ \value Patches Only primitive type accepted by tesselation shader where a patch consists of arbitrary number of vertices
+ */
+
+/*!
+ \qmlproperty int GeometryView::instanceCount
+
+ Holds the instance count.
+ */
+
+/*!
+ \qmlproperty int GeometryView::vertexCount
+
+ Holds the vertex count.
+ */
+
+/*!
+ \qmlproperty int GeometryView::indexOffset
+
+ Holds the base vertex.
+ */
+
+/*!
+ \qmlproperty int GeometryView::firstInstance
+
+ Holds the base instance.
+ */
+
+/*!
+ \qmlproperty int GeometryView::firstVertex
+
+ Holds the first vertex.
+ */
+
+/*!
+ \qmlproperty int GeometryView::indexBufferByteOffset
+
+ Holds the byte offset into the index buffer.
+ */
+
+/*!
+ \qmlproperty int GeometryView::restartIndex
+
+ Holds the restart index.
+ */
+
+/*!
+ \qmlproperty int GeometryView::verticesPerPatch
+
+ Holds vertices per patch.
+ */
+
+/*!
+ \qmlproperty bool GeometryView::primitiveRestart
+
+ Holds the primitive restart flag.
+ */
+
+/*!
+ \qmlproperty Geometry GeometryView::geometry
+
+ Holds the geometry.
+ */
+
+/*!
+ \qmlproperty enumeration GeometryView::primitiveType
+
+ Holds the primitive type.
+
+ \list
+ \li QGeometryView.Points
+ \li QGeometryView.Lines
+ \li QGeometryView.LineLoop
+ \li QGeometryView.LineStrip
+ \li QGeometryView.Triangles
+ \li QGeometryView.TriangleStrip
+ \li QGeometryView.TriangleFan
+ \li QGeometryView.LinesAdjacency
+ \li QGeometryView.TrianglesAdjacency
+ \li QGeometryView.LineStripAdjacency
+ \li QGeometryView.TriangleStripAdjacency
+ \li QGeometryView.Patches
+ \endlist
+ \sa Qt3DCore::QGeometryView::PrimitiveType
+ */
+
+
+/*!
+ Constructs a new QGeometryView with \a parent.
+ */
+QGeometryView::QGeometryView(QNode *parent)
+ : QNode(*new QGeometryViewPrivate(), parent)
+{
+}
+
+/*!
+ \internal
+ */
+QGeometryView::~QGeometryView()
+{
+}
+
+/*!
+ \internal
+ */
+QGeometryView::QGeometryView(QGeometryViewPrivate &dd, QNode *parent)
+ : QNode(dd, parent)
+{
+}
+
+/*!
+ \property QGeometryView::instanceCount
+
+ Holds the instance count.
+ */
+int QGeometryView::instanceCount() const
+{
+ Q_D(const QGeometryView);
+ return d->m_instanceCount;
+}
+
+/*!
+ \property QGeometryView::vertexCount
+
+ Holds the primitive count.
+ */
+int QGeometryView::vertexCount() const
+{
+ Q_D(const QGeometryView);
+ return d->m_vertexCount;
+}
+
+/*!
+ \property QGeometryView::indexOffset
+
+ Holds the base vertex.
+ */
+int QGeometryView::indexOffset() const
+{
+ Q_D(const QGeometryView);
+ return d->m_indexOffset;
+}
+
+/*!
+ \property QGeometryView::firstInstance
+
+ Holds the base instance.
+ */
+int QGeometryView::firstInstance() const
+{
+ Q_D(const QGeometryView);
+ return d->m_firstInstance;
+}
+
+/*!
+ \property QGeometryView::firstVertex
+
+ Holds the base vertex.
+ */
+int QGeometryView::firstVertex() const
+{
+ Q_D(const QGeometryView);
+ return d->m_firstVertex;
+}
+
+/*!
+ \property QGeometryView::indexBufferByteOffset
+
+ Holds the byte offset into the index buffer.
+ */
+int QGeometryView::indexBufferByteOffset() const
+{
+ Q_D(const QGeometryView);
+ return d->m_indexBufferByteOffset;
+}
+
+/*!
+ \property QGeometryView::restartIndexValue
+
+ Holds the restart index.
+ */
+int QGeometryView::restartIndexValue() const
+{
+ Q_D(const QGeometryView);
+ return d->m_restartIndexValue;
+}
+
+/*!
+ \property QGeometryView::verticesPerPatch
+
+ Holds vertices per patch.
+ */
+int QGeometryView::verticesPerPatch() const
+{
+ Q_D(const QGeometryView);
+ return d->m_verticesPerPatch;
+}
+
+/*!
+ \property QGeometryView::primitiveRestartEnabled
+
+ Holds the primitive restart flag.
+ */
+bool QGeometryView::primitiveRestartEnabled() const
+{
+ Q_D(const QGeometryView);
+ return d->m_primitiveRestart;
+}
+
+/*!
+ \property QGeometryView::geometry
+
+ Holds the geometry.
+ */
+QGeometry *QGeometryView::geometry() const
+{
+ Q_D(const QGeometryView);
+ return d->m_geometry;
+}
+
+/*!
+ \property QGeometryView::primitiveType
+
+ Holds the primitive type.
+ */
+QGeometryView::PrimitiveType QGeometryView::primitiveType() const
+{
+ Q_D(const QGeometryView);
+ return d->m_primitiveType;
+}
+
+void QGeometryView::setInstanceCount(int instanceCount)
+{
+ Q_D(QGeometryView);
+ if (d->m_instanceCount == instanceCount)
+ return;
+
+ d->m_instanceCount = instanceCount;
+ emit instanceCountChanged(instanceCount);
+}
+
+void QGeometryView::setVertexCount(int vertexCount)
+{
+ Q_D(QGeometryView);
+ if (d->m_vertexCount == vertexCount)
+ return;
+
+ d->m_vertexCount = vertexCount;
+ emit vertexCountChanged(vertexCount);
+}
+
+void QGeometryView::setIndexOffset(int indexOffset)
+{
+ Q_D(QGeometryView);
+ if (d->m_indexOffset == indexOffset)
+ return;
+
+ d->m_indexOffset = indexOffset;
+ emit indexOffsetChanged(indexOffset);
+}
+
+void QGeometryView::setFirstInstance(int firstInstance)
+{
+ Q_D(QGeometryView);
+ if (d->m_firstInstance == firstInstance)
+ return;
+
+ d->m_firstInstance = firstInstance;
+ emit firstInstanceChanged(firstInstance);
+}
+
+void QGeometryView::setFirstVertex(int firstVertex)
+{
+ Q_D(QGeometryView);
+ if (d->m_firstVertex == firstVertex)
+ return;
+
+ d->m_firstVertex = firstVertex;
+ emit firstVertexChanged(firstVertex);
+}
+
+void QGeometryView::setIndexBufferByteOffset(int offset)
+{
+ Q_D(QGeometryView);
+ if (d->m_indexBufferByteOffset == offset)
+ return;
+
+ d->m_indexBufferByteOffset = offset;
+ emit indexBufferByteOffsetChanged(offset);
+}
+
+void QGeometryView::setRestartIndexValue(int index)
+{
+ Q_D(QGeometryView);
+ if (index == d->m_restartIndexValue)
+ return;
+
+ d->m_restartIndexValue = index;
+ emit restartIndexValueChanged(index);
+}
+
+void QGeometryView::setVerticesPerPatch(int verticesPerPatch)
+{
+ Q_D(QGeometryView);
+ if (d->m_verticesPerPatch != verticesPerPatch) {
+ d->m_verticesPerPatch = verticesPerPatch;
+ emit verticesPerPatchChanged(verticesPerPatch);
+ }
+}
+
+void QGeometryView::setPrimitiveRestartEnabled(bool enabled)
+{
+ Q_D(QGeometryView);
+ if (enabled == d->m_primitiveRestart)
+ return;
+
+ d->m_primitiveRestart = enabled;
+ emit primitiveRestartEnabledChanged(enabled);
+}
+
+void QGeometryView::setGeometry(QGeometry *geometry)
+{
+ Q_D(QGeometryView);
+ if (d->m_geometry == geometry)
+ return;
+
+ if (d->m_geometry)
+ d->unregisterDestructionHelper(d->m_geometry);
+
+ if (geometry && !geometry->parent())
+ geometry->setParent(this);
+
+ d->m_geometry = geometry;
+
+ // Ensures proper bookkeeping
+ if (d->m_geometry)
+ d->registerDestructionHelper(d->m_geometry, &QGeometryView::setGeometry, d->m_geometry);
+
+ emit geometryChanged(geometry);
+}
+
+void QGeometryView::setPrimitiveType(QGeometryView::PrimitiveType primitiveType)
+{
+ Q_D(QGeometryView);
+ if (d->m_primitiveType == primitiveType)
+ return;
+
+ d->m_primitiveType = primitiveType;
+ emit primitiveTypeChanged(primitiveType);
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/geometry/qgeometryview.h b/src/core/geometry/qgeometryview.h
new file mode 100644
index 000000000..da76f3de0
--- /dev/null
+++ b/src/core/geometry/qgeometryview.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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_QGEOMETRYVIEW_H
+#define QT3DCORE_QGEOMETRYVIEW_H
+
+#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/qgeometry.h>
+#include <Qt3DCore/qt3dcore_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QGeometryViewPrivate;
+class QGeometryFactory;
+
+typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr;
+
+class Q_3DCORESHARED_EXPORT QGeometryView : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged)
+ Q_PROPERTY(int vertexCount READ vertexCount WRITE setVertexCount NOTIFY vertexCountChanged)
+ Q_PROPERTY(int indexOffset READ indexOffset WRITE setIndexOffset NOTIFY indexOffsetChanged)
+ Q_PROPERTY(int firstInstance READ firstInstance WRITE setFirstInstance NOTIFY firstInstanceChanged)
+ Q_PROPERTY(int firstVertex READ firstVertex WRITE setFirstVertex NOTIFY firstVertexChanged)
+ Q_PROPERTY(int indexBufferByteOffset READ indexBufferByteOffset WRITE setIndexBufferByteOffset NOTIFY indexBufferByteOffsetChanged)
+ 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(Qt3DCore::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
+ Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged)
+
+public:
+ explicit QGeometryView(Qt3DCore::QNode *parent = nullptr);
+ ~QGeometryView();
+
+ enum PrimitiveType {
+ Points = 0x0000,
+ Lines = 0x0001,
+ LineLoop = 0x0002,
+ LineStrip = 0x0003,
+ Triangles = 0x0004,
+ TriangleStrip = 0x0005,
+ TriangleFan = 0x0006,
+ LinesAdjacency = 0x000A,
+ TrianglesAdjacency = 0x000C,
+ LineStripAdjacency = 0x000B,
+ TriangleStripAdjacency = 0x000D,
+ Patches = 0x000E
+ };
+ Q_ENUM(PrimitiveType) // LCOV_EXCL_LINE
+
+ // how to figure out index count and all the fancy stuff that QMeshData provides for us?
+ // also how to figure out which attribute(s?) hold the indices?
+
+ int instanceCount() const;
+ int vertexCount() const;
+ int indexOffset() const;
+ int firstInstance() const;
+ int firstVertex() const;
+ int indexBufferByteOffset() const;
+ int restartIndexValue() const;
+ int verticesPerPatch() const;
+ bool primitiveRestartEnabled() const;
+ QGeometry *geometry() const;
+ PrimitiveType primitiveType() const;
+
+ QGeometryFactoryPtr geometryFactory() const;
+ void setGeometryFactory(const QGeometryFactoryPtr &factory);
+
+public Q_SLOTS:
+ void setInstanceCount(int instanceCount);
+ void setVertexCount(int vertexCount);
+ void setIndexOffset(int indexOffset);
+ void setFirstInstance(int firstInstance);
+ void setFirstVertex(int firstVertex);
+ void setIndexBufferByteOffset(int offset);
+ void setRestartIndexValue(int index);
+ void setVerticesPerPatch(int verticesPerPatch);
+ void setPrimitiveRestartEnabled(bool enabled);
+ void setGeometry(QGeometry *geometry);
+ void setPrimitiveType(PrimitiveType primitiveType);
+
+Q_SIGNALS:
+ void instanceCountChanged(int instanceCount);
+ void vertexCountChanged(int vertexCount);
+ void indexOffsetChanged(int indexOffset);
+ void firstInstanceChanged(int firstInstance);
+ void firstVertexChanged(int firstVertex);
+ void indexBufferByteOffsetChanged(int offset);
+ void restartIndexValueChanged(int restartIndexValue);
+ void verticesPerPatchChanged(int verticesPerPatch);
+ void primitiveRestartEnabledChanged(bool primitiveRestartEnabled);
+ void geometryChanged(QGeometry *geometry);
+ void primitiveTypeChanged(PrimitiveType primitiveType);
+
+protected:
+ explicit QGeometryView(QGeometryViewPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QGeometryView)
+};
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QGEOMETRYVIEW_H
diff --git a/src/core/geometry/qgeometryview_p.h b/src/core/geometry/qgeometryview_p.h
new file mode 100644
index 000000000..ff8ff4880
--- /dev/null
+++ b/src/core/geometry/qgeometryview_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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_QGEOMETRYVIEW_P_H
+#define QT3DCORE_QGEOMETRYVIEW_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 <Qt3DCore/private/qnode_p.h>
+#include <Qt3DCore/qgeometryview.h>
+#include <Qt3DCore/private/qgeometryfactory_p.h>
+#include <Qt3DCore/private/qt3dcore_global_p.h>
+#include <memory>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class Q_3DCORESHARED_EXPORT QGeometryViewPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QGeometryViewPrivate();
+ ~QGeometryViewPrivate();
+
+ Q_DECLARE_PUBLIC(QGeometryView)
+
+ int m_instanceCount;
+ int m_vertexCount;
+ int m_indexOffset;
+ int m_firstInstance;
+ int m_firstVertex;
+ int m_indexBufferByteOffset;
+ int m_restartIndexValue;
+ int m_verticesPerPatch;
+ bool m_primitiveRestart;
+ QGeometry *m_geometry;
+ QGeometryView::PrimitiveType m_primitiveType;
+};
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+
+
+#endif // QT3DCORE_QGEOMETRYVIEW_P_H
+
diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
index a15629b68..8576e113b 100644
--- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
+++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
@@ -47,6 +47,7 @@
#include <Qt3DCore/qattribute.h>
#include <Qt3DCore/qbuffer.h>
#include <Qt3DCore/qgeometry.h>
+#include <Qt3DCore/qgeometryview.h>
#include <QtCore/qvariantanimation.h>
#include <Qt3DQuick/private/quick3dnodev9_p.h>
@@ -85,6 +86,7 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<Qt3DCore::QBuffer, 9>(uri, 2, 9, "BufferBase", QStringLiteral("Use Quick3DBuffer in QML"));
qmlRegisterType<Qt3DCore::Quick::Quick3DBuffer>(uri, 2, 0, "Buffer");
Qt3DCore::Quick::registerExtendedType<Qt3DCore::QGeometry, Qt3DCore::Quick::Quick3DGeometry>("QGeometry", "Qt3D.Core/Geometry", uri, 2, 0, "Geometry");
+ qmlRegisterType<Qt3DCore::QGeometryView>(uri, 2, 16, "GeometryView");
qmlRegisterType<Qt3DCore::Quick::QQuaternionAnimation>(uri, 2, 0, "QuaternionAnimation");
qRegisterAnimationInterpolator<QQuaternion>(Qt3DCore::Quick::q_quaternionInterpolator);
diff --git a/src/render/geometry/geometryrenderer.cpp b/src/render/geometry/geometryrenderer.cpp
index 6f6227ba7..5a4bdcd9c 100644
--- a/src/render/geometry/geometryrenderer.cpp
+++ b/src/render/geometry/geometryrenderer.cpp
@@ -107,46 +107,55 @@ void GeometryRenderer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
const QGeometryRenderer *node = qobject_cast<const QGeometryRenderer *>(frontEnd);
if (!node)
return;
-
- m_dirty |= m_instanceCount != node->instanceCount();
- m_instanceCount = node->instanceCount();
- m_dirty |= m_vertexCount != node->vertexCount();
- m_vertexCount = node->vertexCount();
- m_dirty |= m_indexOffset != node->indexOffset();
- m_indexOffset = node->indexOffset();
- m_dirty |= m_firstInstance != node->firstInstance();
- m_firstInstance = node->firstInstance();
- m_dirty |= m_firstVertex != node->firstVertex();
- m_firstVertex = node->firstVertex();
- m_dirty |= m_indexBufferByteOffset != node->indexBufferByteOffset();
- m_indexBufferByteOffset = node->indexBufferByteOffset();
- m_dirty |= m_restartIndexValue != node->restartIndexValue();
- m_restartIndexValue = node->restartIndexValue();
- m_dirty |= m_verticesPerPatch != node->verticesPerPatch();
- m_verticesPerPatch = node->verticesPerPatch();
- m_dirty |= m_primitiveRestartEnabled != node->primitiveRestartEnabled();
- m_primitiveRestartEnabled = node->primitiveRestartEnabled();
- m_dirty |= m_primitiveType != node->primitiveType();
- m_primitiveType = node->primitiveType();
- m_dirty |= (node->geometry() && m_geometryId != node->geometry()->id()) || (!node->geometry() && !m_geometryId.isNull());
- m_geometryId = node->geometry() ? node->geometry()->id() : Qt3DCore::QNodeId();
-
- const QGeometryRendererPrivate *dnode = static_cast<const QGeometryRendererPrivate *>(QNodePrivate::get(frontEnd));
- QGeometryFactoryPtr newFunctor = dnode->m_geometryFactory;
- const bool functorDirty = ((m_geometryFactory && !newFunctor)
- || (!m_geometryFactory && newFunctor)
- || (m_geometryFactory && newFunctor && !(*newFunctor == *m_geometryFactory)));
- if (functorDirty) {
- m_dirty = true;
- m_geometryFactory = newFunctor;
- if (m_geometryFactory && m_manager != nullptr) {
- m_manager->addDirtyGeometryRenderer(peerId());
-
- const bool isQMeshFunctor = m_geometryFactory->id() == Qt3DCore::functorTypeId<MeshLoaderFunctor>();
- if (isQMeshFunctor) {
- const QMesh *meshNode = static_cast<const QMesh *>(node);
- QMeshPrivate *dmeshNode = QMeshPrivate::get(const_cast<QMesh *>(meshNode));
- dmeshNode->setStatus(QMesh::Loading);
+ const Qt3DCore::QGeometryView *view = node->view();
+
+ auto propertyUpdater = [this](const auto *node) {
+ m_dirty |= m_instanceCount != node->instanceCount();
+ m_instanceCount = node->instanceCount();
+ m_dirty |= m_vertexCount != node->vertexCount();
+ m_vertexCount = node->vertexCount();
+ m_dirty |= m_indexOffset != node->indexOffset();
+ m_indexOffset = node->indexOffset();
+ m_dirty |= m_firstInstance != node->firstInstance();
+ m_firstInstance = node->firstInstance();
+ m_dirty |= m_firstVertex != node->firstVertex();
+ m_firstVertex = node->firstVertex();
+ m_dirty |= m_indexBufferByteOffset != node->indexBufferByteOffset();
+ m_indexBufferByteOffset = node->indexBufferByteOffset();
+ m_dirty |= m_restartIndexValue != node->restartIndexValue();
+ m_restartIndexValue = node->restartIndexValue();
+ m_dirty |= m_verticesPerPatch != node->verticesPerPatch();
+ m_verticesPerPatch = node->verticesPerPatch();
+ m_dirty |= m_primitiveRestartEnabled != node->primitiveRestartEnabled();
+ m_primitiveRestartEnabled = node->primitiveRestartEnabled();
+ m_dirty |= m_primitiveType != static_cast<QGeometryRenderer::PrimitiveType>(node->primitiveType());
+ m_primitiveType = static_cast<QGeometryRenderer::PrimitiveType>(node->primitiveType());
+ m_dirty |= (node->geometry() && m_geometryId != node->geometry()->id()) || (!node->geometry() && !m_geometryId.isNull());
+ m_geometryId = node->geometry() ? node->geometry()->id() : Qt3DCore::QNodeId();
+ };
+
+ if (view) {
+ propertyUpdater(view);
+ } else {
+ propertyUpdater(node);
+
+ const QGeometryRendererPrivate *dnode = static_cast<const QGeometryRendererPrivate *>(QNodePrivate::get(frontEnd));
+ QGeometryFactoryPtr newFunctor = dnode->m_geometryFactory;
+ const bool functorDirty = ((m_geometryFactory && !newFunctor)
+ || (!m_geometryFactory && newFunctor)
+ || (m_geometryFactory && newFunctor && !(*newFunctor == *m_geometryFactory)));
+ if (functorDirty) {
+ m_dirty = true;
+ m_geometryFactory = newFunctor;
+ if (m_geometryFactory && m_manager != nullptr) {
+ m_manager->addDirtyGeometryRenderer(peerId());
+
+ const bool isQMeshFunctor = m_geometryFactory->id() == Qt3DCore::functorTypeId<MeshLoaderFunctor>();
+ if (isQMeshFunctor) {
+ const QMesh *meshNode = static_cast<const QMesh *>(node);
+ QMeshPrivate *dmeshNode = QMeshPrivate::get(const_cast<QMesh *>(meshNode));
+ dmeshNode->setStatus(QMesh::Loading);
+ }
}
}
}
diff --git a/src/render/geometry/qgeometryrenderer.cpp b/src/render/geometry/qgeometryrenderer.cpp
index 11a5460d0..f9029f099 100644
--- a/src/render/geometry/qgeometryrenderer.cpp
+++ b/src/render/geometry/qgeometryrenderer.cpp
@@ -61,6 +61,7 @@ QGeometryRendererPrivate::QGeometryRendererPrivate()
, m_primitiveRestart(false)
, m_geometry(nullptr)
, m_primitiveType(QGeometryRenderer::Triangles)
+ , m_view(nullptr)
{
}
@@ -339,6 +340,12 @@ QGeometryRenderer::PrimitiveType QGeometryRenderer::primitiveType() const
return d->m_primitiveType;
}
+QGeometryView *QGeometryRenderer::view() const
+{
+ Q_D(const QGeometryRenderer);
+ return d->m_view;
+}
+
void QGeometryRenderer::setInstanceCount(int instanceCount)
{
Q_D(QGeometryRenderer);
@@ -459,6 +466,41 @@ void QGeometryRenderer::setPrimitiveType(QGeometryRenderer::PrimitiveType primit
emit primitiveTypeChanged(primitiveType);
}
+void QGeometryRenderer::setView(QGeometryView *view)
+{
+ Q_D(QGeometryRenderer);
+ if (d->m_view == view)
+ return;
+
+ if (d->m_view) {
+ d->unregisterDestructionHelper(d->m_view);
+ d->m_view->disconnect(this);
+ }
+
+ if (view && !view->parent())
+ view->setParent(this);
+
+ d->m_view = view;
+
+ // Ensures proper bookkeeping
+ if (d->m_view) {
+ d->registerDestructionHelper(d->m_view, &QGeometryRenderer::setView, d->m_view);
+ connect(view, &QGeometryView::instanceCountChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::vertexCountChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::indexOffsetChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::firstInstanceChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::firstVertexChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::indexBufferByteOffsetChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::restartIndexValueChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::verticesPerPatchChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::primitiveRestartEnabledChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::geometryChanged, this, [d]() { d->update(); });
+ connect(view, &QGeometryView::primitiveTypeChanged, this, [d]() { d->update(); });
+ }
+
+ emit viewChanged(view);
+}
+
} // namespace Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/geometry/qgeometryrenderer.h b/src/render/geometry/qgeometryrenderer.h
index 435a315ad..0eee34b86 100644
--- a/src/render/geometry/qgeometryrenderer.h
+++ b/src/render/geometry/qgeometryrenderer.h
@@ -42,16 +42,11 @@
#include <Qt3DCore/qcomponent.h>
#include <Qt3DCore/qgeometry.h>
+#include <Qt3DCore/qgeometryview.h>
#include <Qt3DRender/qt3drender_global.h>
QT_BEGIN_NAMESPACE
-namespace Qt3DCore {
-class QGeometryFactory;
-
-typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr;
-}
-
namespace Qt3DRender {
class QGeometryRendererPrivate;
@@ -70,7 +65,7 @@ class Q_3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QComponent
Q_PROPERTY(bool primitiveRestartEnabled READ primitiveRestartEnabled WRITE setPrimitiveRestartEnabled NOTIFY primitiveRestartEnabledChanged)
Q_PROPERTY(Qt3DCore::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged)
-
+ Q_PROPERTY(Qt3DCore::QGeometryView* view READ view WRITE setView NOTIFY viewChanged)
public:
explicit QGeometryRenderer(Qt3DCore::QNode *parent = nullptr);
~QGeometryRenderer();
@@ -105,6 +100,7 @@ public:
bool primitiveRestartEnabled() const;
Qt3DCore::QGeometry *geometry() const;
PrimitiveType primitiveType() const;
+ Qt3DCore::QGeometryView *view() const;
public Q_SLOTS:
void setInstanceCount(int instanceCount);
@@ -118,6 +114,7 @@ public Q_SLOTS:
void setPrimitiveRestartEnabled(bool enabled);
void setGeometry(Qt3DCore::QGeometry *geometry);
void setPrimitiveType(PrimitiveType primitiveType);
+ void setView(Qt3DCore::QGeometryView *view);
Q_SIGNALS:
void instanceCountChanged(int instanceCount);
@@ -131,6 +128,7 @@ Q_SIGNALS:
void primitiveRestartEnabledChanged(bool primitiveRestartEnabled);
void geometryChanged(Qt3DCore::QGeometry *geometry);
void primitiveTypeChanged(PrimitiveType primitiveType);
+ void viewChanged(Qt3DCore::QGeometryView *view);
protected:
explicit QGeometryRenderer(QGeometryRendererPrivate &dd, Qt3DCore::QNode *parent = nullptr);
diff --git a/src/render/geometry/qgeometryrenderer_p.h b/src/render/geometry/qgeometryrenderer_p.h
index ab2a3f0f8..5bacb74c4 100644
--- a/src/render/geometry/qgeometryrenderer_p.h
+++ b/src/render/geometry/qgeometryrenderer_p.h
@@ -81,6 +81,7 @@ public:
Qt3DCore::QGeometry *m_geometry;
QGeometryRenderer::PrimitiveType m_primitiveType;
Qt3DCore::QGeometryFactoryPtr m_geometryFactory;
+ Qt3DCore::QGeometryView *m_view;
};
} // namespace Qt3DRender