Page 1 of 1

setParent or addChild

Posted: Thu Sep 14, 2006 3:39 am
by Zar
I would like to know if there is any difference/advantage between attaching a scene node to a camera using node->setParent(camera); or camera->addChild(node), besides the order of declarations?

I'm testing both with the same results.

Posted: Thu Sep 14, 2006 4:02 am
by vitek
They have the same effect. setParent() can be used to set the parent to NULL if you want to remove a node from the scene graph temporarily. It calls addChild() if the parent you specified is a valid pointer, so setParent() is a tiny bit more expensive.

Posted: Thu Sep 14, 2006 6:23 am
by Zar
vitek wrote:They have the same effect. setParent() can be used to set the parent to NULL if you want to remove a node from the scene graph temporarily. It calls addChild() if the parent you specified is a valid pointer, so setParent() is a tiny bit more expensive.
@vitek

Thanks a lot!