diff options
author | Antti Määttä <antti.maatta@qt.io> | 2017-02-13 12:10:32 +0200 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2017-02-13 12:24:28 +0000 |
commit | 88b24df43916442785238966d5a3c3eb77b2d097 (patch) | |
tree | 510823f5cb9b56150d78c0aa957287c36e527936 | |
parent | 6a5838c8e819c462404cf74c98c5e433be26d1b7 (diff) |
Fix crash when running 3d-text examplev5.9.0-alpha1
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 <sean.harmer@kdab.com>
-rw-r--r-- | src/extras/3dtext/qtext3dgeometry.cpp | 7 |
1 files 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(); |