summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2014-11-18 11:21:41 +0200
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2014-11-18 11:22:45 +0200
commit79bcab5c2a2be73d20364e7ccd718856659510cc (patch)
treed54bde658b37021d254167cc1de96d43c810f9f6
parent4a8a1e06f12a8b9d16696a4c559c325f771cad0c (diff)
parent11ed44c13c227c73d9b2ec416aed54b00bda2a0a (diff)
Merge branch 'develop'
-rw-r--r--dist/changes-1.2.01
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-index.qdoc2
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization.qdoc2
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp2
-rw-r--r--src/datavisualization/engine/drawer.cpp6
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp6
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp3
-rw-r--r--src/datavisualization/utils/abstractobjecthelper.cpp5
-rw-r--r--src/datavisualization/utils/abstractobjecthelper_p.h3
-rw-r--r--src/datavisualization/utils/objecthelper.cpp3
-rw-r--r--src/datavisualization/utils/objecthelper_p.h4
-rw-r--r--src/datavisualization/utils/scatterobjectbufferhelper.cpp3
-rw-r--r--src/datavisualization/utils/scatterpointbufferhelper.cpp1
-rw-r--r--src/datavisualization/utils/surfaceobject.cpp1
-rw-r--r--src/datavisualization/utils/vertexindexer.cpp85
-rw-r--r--src/datavisualization/utils/vertexindexer_p.h26
-rw-r--r--tests/auto/auto.pro2
17 files changed, 27 insertions, 128 deletions
diff --git a/dist/changes-1.2.0 b/dist/changes-1.2.0
index b23d83b1..c84608e2 100644
--- a/dist/changes-1.2.0
+++ b/dist/changes-1.2.0
@@ -64,6 +64,7 @@ General:
- Fixed a crash related to selection render buffer reuse.
- Fixed the flipped Z-coordinate for absolutely positioned custom items.
- Fixed shadows when viewing the graph directly from above or below.
+- Fixed problems using large custom meshes where vertex index count overflowed unsigned short.
New examples
------------
diff --git a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
index 711573c9..9170baeb 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
@@ -35,12 +35,14 @@
\list
\li Control viewable data window with axis ranges
\li Customize value axis grid lines and labels with axis formatters
+ \li Polar horizontal axes support for surface and scatter graphs
\endlist
\li Customizable input handling
\li Customizable themes
\li Custom items and labels can be added to any graph
\li Ready-made data proxies to visualize data from Qt item models and height maps
\li Perspective and orthographic projections
+ \li Volumetric custom items
\endlist
\section1 Getting Started
diff --git a/src/datavisualization/doc/src/qtdatavisualization.qdoc b/src/datavisualization/doc/src/qtdatavisualization.qdoc
index b6312060..ab245a88 100644
--- a/src/datavisualization/doc/src/qtdatavisualization.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization.qdoc
@@ -192,7 +192,7 @@
\section1 Series
- Series is combination of logically connected set of data items (handled by a data proxy)
+ A series is a combination of a logically connected set of data items (handled by a data proxy)
and visual properties that describe how the data items should be rendered, such as item
meshes and colors. Each visualization type has its own series type. For example, bar graphs
use QBar3DSeries. All graphs can have multiple series added simultaneously.
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 5768cb1a..09b29173 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -1124,7 +1124,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, barObj->elementBuf());
// Draw the triangles
- glDrawElements(GL_TRIANGLES, barObj->indexCount(), GL_UNSIGNED_SHORT,
+ glDrawElements(GL_TRIANGLES, barObj->indexCount(), GL_UNSIGNED_INT,
(void *)0);
// Free buffers
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index 38ad4c1a..63bb2c69 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -142,7 +142,7 @@ void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLui
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf());
// Draw the triangles
- glDrawElements(GL_TRIANGLES, object->indexCount(), object->indicesType(), (void*)0);
+ glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_INT, (void*)0);
// Free buffers
glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -177,7 +177,7 @@ void Drawer::drawSelectionObject(ShaderHelper *shader, AbstractObjectHelper *obj
glBindBuffer(GL_ARRAY_BUFFER, object->vertexBuf());
glVertexAttribPointer(shader->posAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void *)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf());
- glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_SHORT, (void *)0);
+ glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_INT, (void *)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(shader->posAtt());
@@ -194,7 +194,7 @@ void Drawer::drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->gridElementBuf());
// Draw the lines
- glDrawElements(GL_LINES, object->gridIndexCount(), object->indicesType(), (void*)0);
+ glDrawElements(GL_LINES, object->gridIndexCount(), GL_UNSIGNED_INT, (void*)0);
// Free buffers
glBindBuffer(GL_ARRAY_BUFFER, 0);
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index d0db28de..d58ca18e 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -641,8 +641,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dotObj->elementBuf());
// Draw the triangles
- glDrawElements(GL_TRIANGLES, dotObj->indexCount(), GL_UNSIGNED_SHORT,
- (void *)0);
+ glDrawElements(GL_TRIANGLES, dotObj->indexCount(),
+ GL_UNSIGNED_INT, (void *)0);
// Free buffers
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
@@ -662,7 +662,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
// Draw the triangles
glDrawElements(GL_TRIANGLES, object->indexCount(),
- object->indicesType(), (void *)0);
+ GL_UNSIGNED_INT, (void *)0);
// Free buffers
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 6f804d16..c09cc4e3 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1216,8 +1216,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf());
// Draw the triangles
- glDrawElements(GL_TRIANGLES, object->indexCount(),
- object->indicesType(), (void *)0);
+ glDrawElements(GL_TRIANGLES, object->indexCount(), GL_UNSIGNED_INT, (void *)0);
}
}
diff --git a/src/datavisualization/utils/abstractobjecthelper.cpp b/src/datavisualization/utils/abstractobjecthelper.cpp
index c3d0e7bb..245b77d1 100644
--- a/src/datavisualization/utils/abstractobjecthelper.cpp
+++ b/src/datavisualization/utils/abstractobjecthelper.cpp
@@ -74,9 +74,4 @@ GLuint AbstractObjectHelper::indexCount()
return m_indexCount;
}
-GLuint AbstractObjectHelper::indicesType()
-{
- return m_indicesType;
-}
-
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/utils/abstractobjecthelper_p.h b/src/datavisualization/utils/abstractobjecthelper_p.h
index bca765d7..b141a132 100644
--- a/src/datavisualization/utils/abstractobjecthelper_p.h
+++ b/src/datavisualization/utils/abstractobjecthelper_p.h
@@ -45,7 +45,6 @@ public:
virtual GLuint uvBuf();
GLuint elementBuf();
GLuint indexCount();
- GLuint indicesType();
public:
GLuint m_vertexbuffer;
@@ -55,8 +54,6 @@ public:
GLuint m_indexCount;
GLboolean m_meshDataLoaded;
-
- GLuint m_indicesType;
};
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/utils/objecthelper.cpp b/src/datavisualization/utils/objecthelper.cpp
index 0237708f..6441aae2 100644
--- a/src/datavisualization/utils/objecthelper.cpp
+++ b/src/datavisualization/utils/objecthelper.cpp
@@ -25,7 +25,6 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
ObjectHelper::ObjectHelper(const QString &objectFile)
: m_objectFile(objectFile)
{
- m_indicesType = GL_UNSIGNED_SHORT;
load();
}
@@ -158,7 +157,7 @@ void ObjectHelper::load()
glGenBuffers(1, &m_elementbuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(unsigned short),
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(GLuint),
&m_indices.at(0), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
diff --git a/src/datavisualization/utils/objecthelper_p.h b/src/datavisualization/utils/objecthelper_p.h
index 92de3838..7e13e2a3 100644
--- a/src/datavisualization/utils/objecthelper_p.h
+++ b/src/datavisualization/utils/objecthelper_p.h
@@ -48,7 +48,7 @@ public:
static void releaseObjectHelper(const Abstract3DRenderer *cacheId, ObjectHelper *&obj);
inline const QString &objectFile() { return m_objectFile; }
- inline const QVector<unsigned short> &indices() const { return m_indices; }
+ inline const QVector<GLuint> &indices() const { return m_indices; }
inline const QVector<QVector3D> &indexedvertices() const { return m_indexedVertices; }
inline const QVector<QVector2D> &indexedUVs() const { return m_indexedUVs; }
inline const QVector<QVector3D> &indexedNormals() const { return m_indexedNormals; }
@@ -59,7 +59,7 @@ private:
void load();
QString m_objectFile;
- QVector<unsigned short> m_indices;
+ QVector<GLuint> m_indices;
QVector<QVector3D> m_indexedVertices;
QVector<QVector2D> m_indexedUVs;
QVector<QVector3D> m_indexedNormals;
diff --git a/src/datavisualization/utils/scatterobjectbufferhelper.cpp b/src/datavisualization/utils/scatterobjectbufferhelper.cpp
index faa3c164..99b17a96 100644
--- a/src/datavisualization/utils/scatterobjectbufferhelper.cpp
+++ b/src/datavisualization/utils/scatterobjectbufferhelper.cpp
@@ -29,7 +29,6 @@ const GLfloat itemScaler = 3.0f;
ScatterObjectBufferHelper::ScatterObjectBufferHelper()
: m_scaleY(0.0f)
{
- m_indicesType = GL_UNSIGNED_INT;
}
ScatterObjectBufferHelper::~ScatterObjectBufferHelper()
@@ -64,7 +63,7 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal
}
// Index vertices
- const QVector<unsigned short> indices = dotObj->indices();
+ const QVector<GLuint> indices = dotObj->indices();
const QVector<QVector3D> indexed_vertices = dotObj->indexedvertices();
const QVector<QVector2D> indexed_uvs = dotObj->indexedUVs();
const QVector<QVector3D> indexed_normals = dotObj->indexedNormals();
diff --git a/src/datavisualization/utils/scatterpointbufferhelper.cpp b/src/datavisualization/utils/scatterpointbufferhelper.cpp
index 08793fef..139d3fc9 100644
--- a/src/datavisualization/utils/scatterpointbufferhelper.cpp
+++ b/src/datavisualization/utils/scatterpointbufferhelper.cpp
@@ -27,7 +27,6 @@ ScatterPointBufferHelper::ScatterPointBufferHelper()
: m_pointbuffer(0),
m_oldRemoveIndex(-1)
{
- m_indicesType = GL_UNSIGNED_INT;
}
ScatterPointBufferHelper::~ScatterPointBufferHelper()
diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp
index 34f50bf1..6f9ace19 100644
--- a/src/datavisualization/utils/surfaceobject.cpp
+++ b/src/datavisualization/utils/surfaceobject.cpp
@@ -36,7 +36,6 @@ SurfaceObject::SurfaceObject(Surface3DRenderer *renderer)
m_dataDimension(0),
m_oldDataDimension(-1)
{
- m_indicesType = GL_UNSIGNED_INT;
glGenBuffers(1, &m_vertexbuffer);
glGenBuffers(1, &m_normalbuffer);
glGenBuffers(1, &m_uvbuffer);
diff --git a/src/datavisualization/utils/vertexindexer.cpp b/src/datavisualization/utils/vertexindexer.cpp
index c34203da..90528d05 100644
--- a/src/datavisualization/utils/vertexindexer.cpp
+++ b/src/datavisualization/utils/vertexindexer.cpp
@@ -24,45 +24,11 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
int unique_vertices = 0;
-// Returns true if v1 can be considered equal to v2
-bool VertexIndexer::is_near(float v1, float v2)
-{
- return qAbs(v1 - v2) < 0.01f;
-}
-
-// Searches through all already exported vertices for a similar one.
-// Similar = same position + same UVs + same normal
-bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex,
- const QVector2D &in_uv,
- const QVector3D &in_normal,
- QVector<QVector3D> &out_vertices,
- QVector<QVector2D> &out_uvs,
- QVector<QVector3D> &out_normals,
- unsigned short &result)
-{
- // Linear search
- for (int i = 0; i < out_vertices.size(); i++) {
- if (is_near(in_vertex.x() , out_vertices[i].x())
- && is_near(in_vertex.y() , out_vertices[i].y())
- && is_near(in_vertex.z() , out_vertices[i].z())
- && is_near(in_uv.x() , out_uvs [i].x())
- && is_near(in_uv.y() , out_uvs [i].y())
- && is_near(in_normal.x() , out_normals [i].x())
- && is_near(in_normal.y() , out_normals [i].y())
- && is_near(in_normal.z() , out_normals [i].z())) {
- result = i;
- return true;
- }
- }
- // No other vertex could be used instead
- return false;
-}
-
bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed,
- QMap<PackedVertex, unsigned short> &VertexToOutIndex,
- unsigned short &result)
+ QMap<PackedVertex, GLuint> &VertexToOutIndex,
+ GLuint &result)
{
- QMap<PackedVertex, unsigned short>::iterator it = VertexToOutIndex.find(packed);
+ QMap<PackedVertex, GLuint>::iterator it = VertexToOutIndex.find(packed);
if (it == VertexToOutIndex.end()) {
return false;
} else {
@@ -74,20 +40,20 @@ bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed,
void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices,
const QVector<QVector2D> &in_uvs,
const QVector<QVector3D> &in_normals,
- QVector<unsigned short> &out_indices,
+ QVector<GLuint> &out_indices,
QVector<QVector3D> &out_vertices,
QVector<QVector2D> &out_uvs,
QVector<QVector3D> &out_normals)
{
unique_vertices = 0;
- QMap<PackedVertex, unsigned short> VertexToOutIndex;
+ QMap<PackedVertex, GLuint> VertexToOutIndex;
// For each input vertex
for (int i = 0; i < in_vertices.size(); i++) {
PackedVertex packed = {in_vertices[i], in_uvs[i], in_normals[i]};
// Try to find a similar vertex in out_XXXX
- unsigned short index;
+ GLuint index;
bool found = getSimilarVertexIndex_fast(packed, VertexToOutIndex, index);
if (found) {
@@ -97,48 +63,11 @@ void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices,
out_vertices.append(in_vertices[i]);
out_uvs.append(in_uvs[i]);
out_normals.append(in_normals[i]);
- unsigned short newindex = (unsigned short)out_vertices.size() - 1;
+ GLuint newindex = (GLuint)out_vertices.size() - 1;
out_indices.append(newindex);
VertexToOutIndex[packed] = newindex;
}
}
}
-void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices,
- const QVector<QVector2D> &in_uvs,
- const QVector<QVector3D> &in_normals,
- const QVector<QVector3D> &in_tangents,
- const QVector<QVector3D> &in_bitangents,
- QVector<unsigned short> &out_indices,
- QVector<QVector3D> &out_vertices,
- QVector<QVector2D> &out_uvs,
- QVector<QVector3D> &out_normals,
- QVector<QVector3D> &out_tangents,
- QVector<QVector3D> &out_bitangents)
-{
- unique_vertices = 0;
- // For each input vertex
- for (int i = 0; i < in_vertices.size(); i++) {
- // Try to find a similar vertex in out_XXXX
- unsigned short index;
- bool found = getSimilarVertexIndex(in_vertices[i], in_uvs[i], in_normals[i],
- out_vertices, out_uvs, out_normals, index);
-
- if (found) {
- out_indices.append(index);
- // Average the tangents and the bitangents
- out_tangents[index] += in_tangents[i];
- out_bitangents[index] += in_bitangents[i];
- } else {
- unique_vertices++;
- out_vertices.append(in_vertices[i]);
- out_uvs.append(in_uvs[i]);
- out_normals.append(in_normals[i]);
- out_tangents.append(in_tangents[i]);
- out_bitangents.append(in_bitangents[i]);
- out_indices.append((unsigned short)out_vertices.size() - 1);
- }
- }
-}
-
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/utils/vertexindexer_p.h b/src/datavisualization/utils/vertexindexer_p.h
index 2e878fbe..e2e7a7da 100644
--- a/src/datavisualization/utils/vertexindexer_p.h
+++ b/src/datavisualization/utils/vertexindexer_p.h
@@ -51,35 +51,15 @@ public:
static void indexVBO(const QVector<QVector3D> &in_vertices,
const QVector<QVector2D> &in_uvs,
const QVector<QVector3D> &in_normals,
- QVector<unsigned short> &out_indices,
+ QVector<GLuint> &out_indices,
QVector<QVector3D> &out_vertices,
QVector<QVector2D> &out_uvs,
QVector<QVector3D> &out_normals);
- static void indexVBO_TBN(const QVector<QVector3D> &in_vertices,
- const QVector<QVector2D> &in_uvs,
- const QVector<QVector3D> &in_normals,
- const QVector<QVector3D> &in_tangents,
- const QVector<QVector3D> &in_bitangents,
- QVector<unsigned short> &out_indices,
- QVector<QVector3D> &out_vertices,
- QVector<QVector2D> &out_uvs,
- QVector<QVector3D> &out_normals,
- QVector<QVector3D> &out_tangents,
- QVector<QVector3D> &out_bitangents);
-
private:
- static bool is_near(float v1, float v2);
- static bool getSimilarVertexIndex(const QVector3D &in_vertex,
- const QVector2D &in_uv,
- const QVector3D &in_normal,
- QVector<QVector3D> &out_vertices,
- QVector<QVector2D> &out_uvs,
- QVector<QVector3D> &out_normals,
- unsigned short &result);
static bool getSimilarVertexIndex_fast(const PackedVertex &packed,
- QMap<PackedVertex, unsigned short> &VertexToOutIndex,
- unsigned short &result);
+ QMap<PackedVertex, GLuint> &VertexToOutIndex,
+ GLuint &result);
};
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index df2943a4..70ffea39 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,6 +1,6 @@
TEMPLATE = subdirs
-SUBDIRS += cpptest
+!android: SUBDIRS += cpptest
qtHaveModule(quick): SUBDIRS += qmltest