Make SGModelPlacement safe on reinit
Remove old model When init is called multiple times (i.e. reinit). Also allow explicit removal of submodel (= init(0) ).
This commit is contained in:
parent
db509f4075
commit
5ede8c12ba
@ -25,6 +25,7 @@ SGModelPlacement::SGModelPlacement () :
|
||||
_selector(new osg::Switch),
|
||||
_transform(new osg::PositionAttitudeTransform)
|
||||
{
|
||||
_selector->addChild(_transform.get());
|
||||
}
|
||||
|
||||
SGModelPlacement::~SGModelPlacement ()
|
||||
@ -34,10 +35,11 @@ SGModelPlacement::~SGModelPlacement ()
|
||||
void
|
||||
SGModelPlacement::init( osg::Node * model )
|
||||
{
|
||||
// remove previous model (in case of reinit)
|
||||
_transform->removeChild(0,1);
|
||||
if (model != 0) {
|
||||
_transform->addChild(model);
|
||||
}
|
||||
_selector->addChild(_transform.get());
|
||||
_selector->setValue(0, 1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user