diff options
-rw-r--r-- | src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.cpp | 32 | ||||
-rw-r--r-- | src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.cpp b/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.cpp index d2f04ef38f..6bbe236544 100644 --- a/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.cpp +++ b/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.cpp @@ -5,6 +5,10 @@ #include "gridgeometry.h" +#if QT_VERSION_MAJOR == 6 && QT_VERSION_MINOR == 4 +#include <private/qssgrendergeometry_p.h> +#endif + namespace QmlDesigner { namespace Internal { @@ -82,6 +86,34 @@ void GridGeometry::doUpdateGeometry() QVector3D(vertexPtr[lastIndex][0], vertexPtr[lastIndex][1], 0.0)); } +#if QT_VERSION_MAJOR == 6 && QT_VERSION_MINOR == 4 +QSSGRenderGraphObject *GridGeometry::updateSpatialNode(QSSGRenderGraphObject *node) +{ + if (!node) { + markAllDirty(); + auto geometryNode = new QSSGRenderGeometry(); + node = geometryNode; + emit geometryNodeDirty(); + + // This is a work around for the issue of incorrect geometry objects getting matched for + // cached mesh data in QSSGBufferManager::loadRenderMesh in QtQuick3D in 6.4 (see QDS-8516). + // Each setting of stride value increments the generation id of the geometry node. + // By incrementing generation id by different amounts for each grid geometry node we have, + // we can ensure QSSGBufferManager cache never matches wrong mesh data. + // The cache should be cleared of old objects after they are unused for one frame, + // and we use 4 grid objects in total, so max of 8 different generation ids should ensure no + // invalid cache matches. + static int dirtyCount = 0; + if (++dirtyCount > 8) + dirtyCount = 0; + for (int i = 0; i < dirtyCount; ++i) + geometryNode->setStride(stride()); + } + + return QQuick3DGeometry::updateSpatialNode(node); +} +#endif + void GridGeometry::fillVertexData(QByteArray &vertexData) { const int numSubdivs = 1; // number of subdivision lines (i.e. lines between main grid lines) diff --git a/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.h b/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.h index 376c9d3bf4..6df03a38ef 100644 --- a/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.h +++ b/src/tools/qml2puppet/qml2puppet/editor3d/gridgeometry.h @@ -39,6 +39,9 @@ signals: protected: void doUpdateGeometry() override; +#if QT_VERSION_MAJOR == 6 && QT_VERSION_MINOR == 4 + QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; +#endif private: void fillVertexData(QByteArray &vertexData); |