From 493d86fc7330e060c371e8d898dd74c297117fc1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 21 Nov 2002 16:08:30 +0000 Subject: [PATCH] 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. --- NEWS | 3 +++ src/osg/Group.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 704e882d3..61e7158fb 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ OSG News (most significant items from ChangeLog) ================================================ + Added new osgshadowtexture demo which illustrates how to create + dynamic shadow textures in your scene. + Addition osgSim which is NodeKit designed for visual simulation market, currently features high fidelity light points support. diff --git a/src/osg/Group.cpp b/src/osg/Group.cpp index 1ae6de1f2..ed3068ae3 100644 --- a/src/osg/Group.cpp +++ b/src/osg/Group.cpp @@ -160,7 +160,7 @@ bool Group::setChild( unsigned int i, Node* newNode ) if (i<_children.size() && newNode) { - Node* origNode = _children[i].get(); + ref_ptr 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 ); }