diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-10-07 10:17:56 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-08 08:47:47 +0200 |
commit | 48e32cfabed8527ac788142393226ad931d29420 (patch) | |
tree | 56dea39df23e23c26f632216ec0c9e72ab415356 /src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | |
parent | aeb8416d948b69d55dda45ed4ebe85585325fedc (diff) |
All matrices in a batch need to be 2D safe when merging.
If we merge geometry nodes that make actual use of the
z-coordinate, this information becomes lost when merging
and the result is that we end up with an arbitrary
wrongfully applied transformation to the merged element.
Task-number: QTBUG-33897
Change-Id: I6129243e9bb890949023c35dc6b7bce30d31709a
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp')
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index ab67dc5ba9..f25e144674 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -648,6 +648,21 @@ bool Batch::isTranslateOnlyToRoot() const { return only; } +/* + * Iterates through all the nodes in the batch and returns true if the + * nodes are all "2D safe" meaning that they can be merged and that + * the value in the z coordinate is of no consequence. + */ +bool Batch::allMatricesAre2DSafe() const { + Element *e = first; + while (e) { + if (!QMatrix4x4_Accessor::is2DSafe(*e->node->matrix())) + return false; + e = e->nextInBatch; + } + return true; +} + static int qsg_countNodesInBatch(const Batch *batch) { int sum = 0; @@ -1597,11 +1612,11 @@ void Renderer::uploadBatch(Batch *b) bool canMerge = (g->drawingMode() == GL_TRIANGLES || g->drawingMode() == GL_TRIANGLE_STRIP) && b->positionAttribute >= 0 && g->indexType() == GL_UNSIGNED_SHORT - && QMatrix4x4_Accessor::is2DSafe(*gn->matrix()) && (gn->activeMaterial()->flags() & QSGMaterial::CustomCompileStep) == 0 && (((gn->activeMaterial()->flags() & QSGMaterial::RequiresDeterminant) == 0) || (((gn->activeMaterial()->flags() & QSGMaterial_RequiresFullMatrixBit) == 0) && b->isTranslateOnlyToRoot()) - ); + ) + && b->allMatricesAre2DSafe(); b->merged = canMerge; |