Dear Gunnar, I'm very sorry for late reply. I was busy with compiling my project for Android and got back to Scene Graph part of my project only two days ago.
I ended up with very easy algorithm for triangulation of polygons ( http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334) that performs much better than the complex one and suits my needs the best. Thank you for your advices. Regards, Artem 2016-05-10 11:41 GMT+02:00 Gunnar Sletta <gun...@sletta.org>: > 1. Both the transform node and the clip node for the child hierarchy is > managed internally in the QQuickItem and you don't have access to those. > The paint node is just the visual part, hence the name "paint node" :) > > As you don't have access to the item's clip node, you can't do clipping > using this API. Your options would be to either use a ShaderEffect + > ShaderEffectSource to make an opacity mask (like OpactiyMask from > QtGraphicalEffect) or to abuse the knowledge that there will be a clip node > as one of your paint node's direct or close to direct parents. The opacity > mask approach comes at a perf cost and abusing the clip node is subject to > future changes in the structure, so neither options are ideal, but those > are the ones available :p > > 2. Items beneath a clip node are rendered. We can easily reject an entire > sub tree when opacity is 0, but we would have to check the bounds of every > single leaf node in the case of clipping, and we've decided to not do that. > > 3. Nodes will have the OwnedByParent flag set by default, so they will be > gathered along with everything else when the scene graph is nuked upon > window closing. If you take a node out of the scene graph (by receiving > non-null and returning null in updatePaintNode, for instance), you are > yourself responsible for deleting that node as it will no longer be managed > by its parent. > > cheers, > Gunnar > > > > On 09 May 2016, at 22:54, Artem Fedoskin <afedosk...@gmail.com> wrote: > > > > Thank you for your reply Gunnar. > > > > I found a great class for drawing polygons in QML here > http://gitlab.unique-conception.org/qt-libraries/lib-qt-qml-tricks > (QQuickPolygon) and adopted triangulation methods of this class to my needs. > > But as always, a bunch of questions arose :) > > • Initially, I thought that Scene Graph reparents all visual > children of the QQuickItem to the node that is returned from call > UpdatePaintNode. However, when I tried set to return QSGClippingNode from > the parent item's updatePaintNode, nodes of its children QQuickItems > weren't reparented to the clipping node. I also noticed from debugger > output that when I set QQuickItem's property "clip" to true, new > QSGClippingNode is created implicitly, to which all nodes of child > QQuickItems are reparented. How can I do something like native QML clipping > but with my own clipping geometry? > > • Is the node that is hided under the area outside clipping > polygon rendered? I noticed that nodes with 0 opacity in debugger has > "BLOCKED" state whereas hided by clipping nodes has the same state as > visible. > > • In which cases are nodes deleted? If I don't delete a main node > of QQuickItem in cases when boundingRect is empty as I saw in examples from > Qt can I be sure that throughout the whole run of my program the nodes > won't be implicitly deleted by Scene Graph. Is it very important to delete > nodes when boundingRect is empty? > > Thank you very much for your help. You keep my project going :) > > > > Regards, Artem > > > > > > 2016-05-09 11:31 GMT+02:00 Gunnar Sletta <gun...@sletta.org>: > > > > > On 08 May 2016, at 01:22, Artem Fedoskin <afedosk...@gmail.com> wrote: > > > > > > 1. Could you tell me please how one can set custom geometry for > QSGClipNode (not the rectangular one)? Should I just create QSGeometry with > QSGGeometry::defaultAttributes_Point2D() attribute and add vertices? Will > Scene Graph recognize that polygon is closed (I need clipping to have a > form of circle)? > > > > You need to add triangles though, not a polygon outline. And when you > add triangles, closing the polygon is no longer an issue :) > > > > > 2. If I want to maintain a cache for a bunch of QSGTextures and reuse > them for changing texture of QSGSimpleTextureNode how should I delete them? > Should I just explicitly delete them in destructor of QSGNode derived > object in which I hold them? > > > > Yes, you need to manage them yourself and deleting them from a QSGNode > is the most sensible place as QSGNodes will be cleaned up automatically. > > > > > 3. If I set opacity to 0 does this mean that node is not rendered? How > is it different from just taking a node out of a node tree? > > > > The approaches should be pretty much the same thing internally. > > > > cheers, > > Gunnar > > > > > > > > Regards, Artem Fedoskin > > > _______________________________________________ > > > Interest mailing list > > > Interest@qt-project.org > > > http://lists.qt-project.org/mailman/listinfo/interest > > > > > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest