summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick3d/qquickitem3d.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/quick3d/qquickitem3d.cpp b/src/quick3d/qquickitem3d.cpp
index 5e4792648..e8ff72afd 100644
--- a/src/quick3d/qquickitem3d.cpp
+++ b/src/quick3d/qquickitem3d.cpp
@@ -1236,25 +1236,22 @@ void QQuickItem3D::drawChildren(QGLPainter *painter)
if (d->sortChildren == QQuickItem3D::BackToFront) {
// Collect up the transformed z positions of all children.
- QList<qreal> zlist;
+ QList<QPair<qreal, QQuickItem3D*> > zlist;
QMatrix4x4 mv = painter->modelViewMatrix();
for (int index = 0; index < list.size(); ++index) {
QVector3D position = list.at(index)->position();
- zlist.append(mv.map(position).z());
+ zlist.append(QPair<qreal, QQuickItem3D*> (mv.map(position).z(), list.at(index)));
}
- // Sort the item list (Caution: really dumb sort algorithm).
- for (int i = 0; i < list.size() - 1; ++i) {
- for (int j = i + 1; j < list.size(); ++j) {
- if (zlist.at(i) > zlist.at(j)) {
- qSwap(list[i], list[j]);
- qSwap(zlist[i], zlist[j]);
- }
- }
- }
+ qSort(zlist);
+ for (int index = 0; index < zlist.size(); ++index)
+ zlist.at(index).second->draw(painter);
+
+ }
+ else {
+ for (int index = 0; index < list.size(); ++index)
+ list.at(index)->draw(painter);
}
- for (int index = 0; index < list.size(); ++index)
- list.at(index)->draw(painter);
}
/*!