From: ThorstenB Date: Tue, 11 Oct 2011 19:28:37 +0000 (+0200) Subject: Make SGModelPlacement safe on reinit X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5ede8c12ba68cf1a0cda6e6d25c76d21a14612e8;p=simgear.git 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) ). --- diff --git a/simgear/scene/model/placement.cxx b/simgear/scene/model/placement.cxx index 85284492..8d2ab9f2 100644 --- a/simgear/scene/model/placement.cxx +++ b/simgear/scene/model/placement.cxx @@ -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); }