[Interest] Z-sorting and explicit hiding of QSGNodes

Gunnar Sletta gunnar at sletta.org
Mon Feb 9 10:46:54 CET 2015


> On 06 Feb 2015, at 16:22, Thomas Sevaldrud <thomas at silentwings.no> wrote:
> 
> Hi,
> 
> I have two questions regarding QSGNodes. In my application I have used a Repeater with delegate Items to place labels defined in QML on objects in a 3D scene. To achieve this, I made a class derived from QSGSimpleRectNode and QObject with a slot that is called on the containing QWindow's beforeRendering(). This slot method calculates the 2D screen position of the 3D object in question and updates the parent QSGTransformNode accordingly.
> 
> This works quite nice, except that I get my labels in a more or less random depth order. I suspect that they are rendered in the order they are created or inserted into the scene graph. 

yes, this is how it works.

> Is there a way to get z-order sorting of QSGGNodes? 

If you made all your labels children of one QSGNode, you could sort them in the order you preferred yourself. 

> 
> For each label there is also a QuickItem which I could set the z value on, but this item is generally not updated for each rendering frame, only when the label content is changed. The label scenegraph node is updated for each rendering frame, since the 3D camera is continously moving.
> 
> Also, many of these labels will be invisible much of the time, because the end up outside of the 3D scene. Is there a way to say that an SGNode is invisible, and thus avoiding that it is rendered, or do I need to update the corresponding QuickItem again?

You make a node invisible by removing it from the scene graph.

> 
> If the only solution to these two issues is to update the corresponding QuickItem, what is the recommended way of doing this? I need to do this when the GUI and rendering threads are synchronized

QQuickItem::updatePaintNode() or QQuickWindow::before/afterSynchronization is what you are after.

> 
> TIA for any ideas :-)
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list