summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-01 22:03:44 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-01 22:03:44 +0200
commitc9671c35094dc512f0a3a276051708312199403b (patch)
tree86d2a24d779fb32e903c057f372029d3d70287d8
parentfb3e195738ccefc0150e692e944f887767a74c7b (diff)
parent9e23691fc56635d1916b129a94984087f160ef9d (diff)
Merge remote-tracking branch 'origin/tqtc/lts-6.2.6' into tqtc/lts-6.2-opensource
-rw-r--r--.cmake.conf2
-rw-r--r--.qmake.conf2
-rw-r--r--src/datavisualization/data/customrenderitem.cpp3
-rw-r--r--src/datavisualization/data/customrenderitem_p.h2
-rw-r--r--src/datavisualization/data/qcustom3ditem.cpp7
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp11
-rw-r--r--src/datavisualization/utils/meshloader.cpp4
-rw-r--r--src/datavisualization/utils/objecthelper.cpp86
8 files changed, 72 insertions, 45 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 940e347a..6f32ba4d 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,2 +1,2 @@
-set(QT_REPO_MODULE_VERSION "6.2.5")
+set(QT_REPO_MODULE_VERSION "6.2.6")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "")
diff --git a/.qmake.conf b/.qmake.conf
index f5f4840b..032ff445 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,6 +2,6 @@ load(qt_build_config)
DEFINES += QT_NO_JAVA_STYLE_ITERATORS
-MODULE_VERSION = 6.2.5
+MODULE_VERSION = 6.2.6
CONFIG += warning_clean
CMAKE_MODULE_TESTS=-
diff --git a/src/datavisualization/data/customrenderitem.cpp b/src/datavisualization/data/customrenderitem.cpp
index 68e84c44..6279921d 100644
--- a/src/datavisualization/data/customrenderitem.cpp
+++ b/src/datavisualization/data/customrenderitem.cpp
@@ -68,9 +68,10 @@ CustomRenderItem::~CustomRenderItem()
ObjectHelper::releaseObjectHelper(m_renderer, m_object);
}
-void CustomRenderItem::setMesh(const QString &meshFile)
+bool CustomRenderItem::setMesh(const QString &meshFile)
{
ObjectHelper::resetObjectHelper(m_renderer, m_object, meshFile);
+ return m_object ? true : false;
}
void CustomRenderItem::setColorTable(const QList<QRgb> &colors)
diff --git a/src/datavisualization/data/customrenderitem_p.h b/src/datavisualization/data/customrenderitem_p.h
index 196e6aa0..e14b1de4 100644
--- a/src/datavisualization/data/customrenderitem_p.h
+++ b/src/datavisualization/data/customrenderitem_p.h
@@ -59,7 +59,7 @@ public:
inline void setTexture(GLuint texture) { m_texture = texture; }
inline GLuint texture() const { return m_texture; }
- void setMesh(const QString &meshFile);
+ bool setMesh(const QString &meshFile);
inline ObjectHelper *mesh() const { return m_object; }
inline void setScaling(const QVector3D &scaling) { m_scaling = scaling; }
inline const QVector3D &scaling() const { return m_scaling; }
diff --git a/src/datavisualization/data/qcustom3ditem.cpp b/src/datavisualization/data/qcustom3ditem.cpp
index 07e3c809..63ba2b20 100644
--- a/src/datavisualization/data/qcustom3ditem.cpp
+++ b/src/datavisualization/data/qcustom3ditem.cpp
@@ -58,7 +58,9 @@ QT_BEGIN_NAMESPACE
/*! \qmlproperty string Custom3DItem::meshFile
*
* The item mesh file name. The item in the file must be in Wavefront OBJ format and include
- * vertices, normals, and UVs. It also needs to be in triangles.
+ * vertices, normals, and UVs. It also needs to be in triangles. If the file is missing either
+ * normals or UVs, loading will fail with an error message to the console output and the item will
+ * not be rendered.
*/
/*! \qmlproperty string Custom3DItem::textureFile
@@ -203,6 +205,9 @@ QCustom3DItem::~QCustom3DItem()
*
* The item in the file must be in Wavefront OBJ format and include
* vertices, normals, and UVs. It also needs to be in triangles.
+ * If the file is missing either normals or UVs, loading will fail
+ * with an error message to the console output and the item will
+ * not be rendered.
*/
void QCustom3DItem::setMeshFile(const QString &meshFile)
{
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 54487ba1..4a0b1c8f 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -749,8 +749,10 @@ void Abstract3DRenderer::updateCustomData(const QList<QCustom3DItem *> &customIt
CustomRenderItem *renderItem = m_customRenderCache.value(item);
if (!renderItem)
renderItem = addCustomItem(item);
- renderItem->setValid(true);
- renderItem->setIndex(i); // always update index, as it must match the custom item index
+ if (renderItem) {
+ renderItem->setValid(true);
+ renderItem->setIndex(i); // always update index, as it must match the custom item index
+ }
}
// Check render item cache and remove items that are not in customItems list anymore
@@ -1133,7 +1135,10 @@ CustomRenderItem *Abstract3DRenderer::addCustomItem(QCustom3DItem *item)
CustomRenderItem *newItem = new CustomRenderItem();
newItem->setRenderer(this);
newItem->setItemPointer(item); // Store pointer for render item updates
- newItem->setMesh(item->meshFile());
+ if (!newItem->setMesh(item->meshFile())) {
+ delete newItem;
+ return nullptr;
+ }
newItem->setOrigPosition(item->position());
newItem->setOrigScaling(item->scaling());
newItem->setScalingAbsolute(item->isScalingAbsolute());
diff --git a/src/datavisualization/utils/meshloader.cpp b/src/datavisualization/utils/meshloader.cpp
index 274d4a13..fa071a96 100644
--- a/src/datavisualization/utils/meshloader.cpp
+++ b/src/datavisualization/utils/meshloader.cpp
@@ -81,6 +81,10 @@ bool MeshLoader::loadOBJ(const QString &path, QList<QVector3D> &out_vertices,
QStringList set1 = lineContents.at(1).split(slashTag);
QStringList set2 = lineContents.at(2).split(slashTag);
QStringList set3 = lineContents.at(3).split(slashTag);
+ if (set1.length() < 3 || set2.length() < 3 || set3.length() < 3) {
+ qWarning("The file being loaded is missing UVs and/or normals");
+ return false;
+ }
vertexIndex[0] = set1.at(0).toUInt();
vertexIndex[1] = set2.at(0).toUInt();
vertexIndex[2] = set3.at(0).toUInt();
diff --git a/src/datavisualization/utils/objecthelper.cpp b/src/datavisualization/utils/objecthelper.cpp
index f8fa01de..87875a98 100644
--- a/src/datavisualization/utils/objecthelper.cpp
+++ b/src/datavisualization/utils/objecthelper.cpp
@@ -113,10 +113,19 @@ ObjectHelper *ObjectHelper::getObjectHelper(const Abstract3DRenderer *cacheId,
objRef = new ObjectHelperRef;
objRef->refCount = 0;
objRef->obj = new ObjectHelper(objectFile);
- objectTable->insert(objectFile, objRef);
+ if (objRef->obj->m_meshDataLoaded) {
+ objectTable->insert(objectFile, objRef);
+ } else {
+ delete objRef->obj;
+ delete objRef;
+ objRef = nullptr;
+ }
+ }
+ if (objRef) {
+ objRef->refCount++;
+ return objRef->obj;
}
- objRef->refCount++;
- return objRef->obj;
+ return nullptr;
}
void ObjectHelper::load()
@@ -140,41 +149,44 @@ void ObjectHelper::load()
QList<QVector2D> uvs;
QList<QVector3D> normals;
bool loadOk = MeshLoader::loadOBJ(m_objectFile, vertices, uvs, normals);
- if (!loadOk)
- qFatal("loading failed");
-
- // Index vertices
- VertexIndexer::indexVBO(vertices, uvs, normals, m_indices, m_indexedVertices, m_indexedUVs,
- m_indexedNormals);
-
- m_indexCount = m_indices.size();
-
- glGenBuffers(1, &m_vertexbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
- glBufferData(GL_ARRAY_BUFFER, m_indexedVertices.size() * sizeof(QVector3D),
- &m_indexedVertices.at(0),
- GL_STATIC_DRAW);
- glGenBuffers(1, &m_normalbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
- glBufferData(GL_ARRAY_BUFFER, m_indexedNormals.size() * sizeof(QVector3D),
- &m_indexedNormals.at(0),
- GL_STATIC_DRAW);
-
- glGenBuffers(1, &m_uvbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
- glBufferData(GL_ARRAY_BUFFER, m_indexedUVs.size() * sizeof(QVector2D),
- &m_indexedUVs.at(0), GL_STATIC_DRAW);
-
- glGenBuffers(1, &m_elementbuffer);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(GLuint),
- &m_indices.at(0), GL_STATIC_DRAW);
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
- m_meshDataLoaded = true;
+ if (!loadOk) {
+ qCritical() << "Loading" << m_objectFile << "failed";
+ m_meshDataLoaded = false;
+ } else {
+ // Index vertices
+ VertexIndexer::indexVBO(vertices, uvs, normals, m_indices, m_indexedVertices, m_indexedUVs,
+ m_indexedNormals);
+
+ m_indexCount = m_indices.size();
+
+ glGenBuffers(1, &m_vertexbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
+ glBufferData(GL_ARRAY_BUFFER, m_indexedVertices.size() * sizeof(QVector3D),
+ &m_indexedVertices.at(0),
+ GL_STATIC_DRAW);
+
+ glGenBuffers(1, &m_normalbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
+ glBufferData(GL_ARRAY_BUFFER, m_indexedNormals.size() * sizeof(QVector3D),
+ &m_indexedNormals.at(0),
+ GL_STATIC_DRAW);
+
+ glGenBuffers(1, &m_uvbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
+ glBufferData(GL_ARRAY_BUFFER, m_indexedUVs.size() * sizeof(QVector2D),
+ &m_indexedUVs.at(0), GL_STATIC_DRAW);
+
+ glGenBuffers(1, &m_elementbuffer);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(GLuint),
+ &m_indices.at(0), GL_STATIC_DRAW);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ m_meshDataLoaded = true;
+ }
}
QT_END_NAMESPACE