Added use of ref_ptr<> for the replaced node in osg::Group::replaceChild(,)

to prevent it being deleted while it was still being used with the body of
the method.

Added mention of the shadow texture demo.
This commit is contained in:
Robert Osfield
2002-11-21 16:08:30 +00:00
parent a545f3b48c
commit 493d86fc73
2 changed files with 26 additions and 2 deletions

View File

@@ -160,7 +160,7 @@ bool Group::setChild( unsigned int i, Node* newNode )
if (i<_children.size() && newNode)
{
Node* origNode = _children[i].get();
ref_ptr<Node> origNode = _children[i];
// first remove for origNode's parent list.
origNode->removeParent(this);
@@ -213,7 +213,28 @@ bool Group::setChild( unsigned int i, Node* newNode )
if (delta_numChildrenWithCullingDisabled!=0)
{
setNumChildrenWithCullingDisabled(
getNumChildrenWithCullingDisabled()-1
getNumChildrenWithCullingDisabled()+delta_numChildrenWithCullingDisabled
);
}
// could now require disabling of culling thanks to the new subgraph,
// so need to check and update if required.
int delta_numChildrenWithOccluderNodes = 0;
if (origNode->getNumChildrenWithOccluderNodes()>0 ||
!origNode->getCullingActive())
{
--delta_numChildrenWithOccluderNodes;
}
if (newNode->getNumChildrenWithOccluderNodes()>0 ||
!newNode->getCullingActive())
{
++delta_numChildrenWithOccluderNodes;
}
if (delta_numChildrenWithOccluderNodes!=0)
{
setNumChildrenWithOccluderNodes(
getNumChildrenWithOccluderNodes()+delta_numChildrenWithOccluderNodes
);
}