I'm using some of the ideas in ISceneNode in my 2D engine.
When creating an ISceneNode you can give it a parent parameter.
If you give it a parent, it's reference counter will increase to 2.
So if you tell the parent to remove the child, it will still exist.
However when creating a clone of the ISceneNode, it drops the extra grab.
Code: Select all
ISceneNode* CBillboardSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
{
if (!newParent)
newParent = Parent;
if (!newManager)
newManager = SceneManager;
CBillboardSceneNode* nb = new CBillboardSceneNode(newParent,
newManager, ID, RelativeTranslation, Size);
nb->cloneMembers(this, newManager);
nb->Material = Material;
nb->drop();
return nb;
}
1. Firstly, am I correct in my assumptions?
2. Secondly just for my understanding, if I am correct, why is it set up like this?
Also, when using clone(), if you don't give the cloned ISceneNode a parent and assuming the node being cloned also does not have a parent, the newly "cloned" ISceneNode will be deleted before it is returned. As it didn't have a parent to grab it an extra time.
I'm not sure if I read the code carefully enough, but that is how it looks.
**EDIT**
Code: Select all
if (newParent)
nb->drop();