DzNode->setNodeParent protected

Alessandro_AMAlessandro_AM Posts: 1,544

Any chance to set a parent node without having to subclass DzNode, since setNodeParent is protected?

Comments

  • rbtwhizrbtwhiz Posts: 436
    edited December 1969

    class DZ_EXPORT DzNode : public DzElement, public DzSceneAsset {
     ...
    public slots:
     ...
     DzError addNodeChild( DzNode *child, bool inPlace = false );
     ...
    };

    -Rob

  • Alessandro_AMAlessandro_AM Posts: 1,544
    edited December 1969

    Thanks Rob, I already tried addNodeChild and didn't work as expected: the children nodes were added to the main one, but would not render.
    Then, I tried to add the child node to the scene, and after that call the addNodeChild. That worked.

    I expected that actually addNodeChild, having that "add" word in it, would automatically add the child node to the scene as well. That misled me.

  • rbtwhizrbtwhiz Posts: 436
    edited December 1969

    DzNode::addNodeChild() doesn't automatically add the node to the scene because you may want to do something to/with that node before it gets drawn. When the scene draws, only those nodes that have already been added to the scene are processed. In cases where there is creation and a parent/child relationship at play... we typically create the node, DzNode::addNodeChild(), do any work based on that relationship and then DzScene::addNode() once we are ready for that node to be displayed to the user. If the node is added to the scene too early, not only can it be a bit disconcerting to the user to see things they shouldn't, it can cause a significant performance hit because there are a number of connections that get made and you begin paying for the drawing.

    -Rob

  • Alessandro_AMAlessandro_AM Posts: 1,544
    edited December 1969

    Thank you very much for the detailed explanation Rob, now that makes sense.

Sign In or Register to comment.
Rocket Fuel