From 88b24df43916442785238966d5a3c3eb77b2d097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 13 Feb 2017 12:10:32 +0200 Subject: Fix crash when running 3d-text example Change the text geometry to use 32-bit index buffer. qTriangulate is using them, which causes the index buffer copy to cause a mess. Also long texts could easily cause vertex buffers with more than 65536 vertices to be generated. Also add check for empty outlines. Task-number: QTBUG-58833 Change-Id: I5ad84081000e6b178a81d6d107aa013f29a95ac5 Reviewed-by: Sean Harmer --- src/extras/3dtext/qtext3dgeometry.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/extras/3dtext/qtext3dgeometry.cpp b/src/extras/3dtext/qtext3dgeometry.cpp index 529c93b79..49db6e4a6 100644 --- a/src/extras/3dtext/qtext3dgeometry.cpp +++ b/src/extras/3dtext/qtext3dgeometry.cpp @@ -65,7 +65,7 @@ namespace Qt3DExtras { namespace { -using IndexType = unsigned short; +using IndexType = unsigned int; struct TriangulationData { struct Outline { @@ -190,7 +190,7 @@ void QText3DGeometryPrivate::init() m_normalAttribute->setCount(0); m_indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute); - m_indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort); + m_indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt); m_indexAttribute->setBuffer(m_indexBuffer); m_indexAttribute->setCount(0); @@ -328,6 +328,9 @@ void QText3DGeometryPrivate::update() const int end = data.outlines[i].end; const int verticesIndexBegin = verticesIndex; + if (begin == end) + continue; + QVector3D prevNormal = QVector3D::crossProduct( vertices[data.outlineIndices[end - 1] + numVertices].position - vertices[data.outlineIndices[end - 1]].position, vertices[data.outlineIndices[begin]].position - vertices[data.outlineIndices[end - 1]].position).normalized(); -- cgit v1.2.3