- remove unused ssgSelector
- add function to remove models
This commit is contained in:
parent
f3cdd7d44a
commit
3b977ee40e
2 changed files with 29 additions and 5 deletions
|
@ -28,8 +28,7 @@ SG_USING_STD(vector);
|
|||
|
||||
FGModelMgr::FGModelMgr ()
|
||||
: _models(fgGetNode("/models", true)),
|
||||
_listener(new Listener(this)),
|
||||
_selector(new ssgSelector)
|
||||
_listener(new Listener(this))
|
||||
|
||||
{
|
||||
_models->addChangeListener(_listener);
|
||||
|
@ -69,6 +68,7 @@ FGModelMgr::add_model (SGPropertyNode * node)
|
|||
Instance * instance = new Instance;
|
||||
SGModelPlacement *model = new SGModelPlacement;
|
||||
instance->model = model;
|
||||
instance->node = node;
|
||||
ssgBranch *object
|
||||
= sgLoad3DModel( globals->get_fg_root(),
|
||||
node->getStringValue("path",
|
||||
|
@ -198,6 +198,7 @@ FGModelMgr::draw ()
|
|||
|
||||
FGModelMgr::Instance::Instance ()
|
||||
: model(0),
|
||||
node(0),
|
||||
lon_deg_node(0),
|
||||
lat_deg_node(0),
|
||||
elev_ft_node(0),
|
||||
|
@ -234,4 +235,28 @@ FGModelMgr::Listener::childAdded(SGPropertyNode * parent, SGPropertyNode * child
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
FGModelMgr::Listener::childRemoved(SGPropertyNode * parent, SGPropertyNode * child)
|
||||
{
|
||||
if (strcmp(parent->getName(), "models") || strcmp(child->getName(), "model"))
|
||||
return;
|
||||
|
||||
// search instance by node and remove it from scenegraph
|
||||
vector<Instance *>::iterator it = _mgr->_instances.begin();
|
||||
vector<Instance *>::iterator end = _mgr->_instances.end();
|
||||
|
||||
for (; it != end; ++it) {
|
||||
Instance *instance = *it;
|
||||
if (instance->node != child)
|
||||
continue;
|
||||
|
||||
_mgr->_instances.erase(it);
|
||||
globals->get_scenery()->get_scene_graph()
|
||||
->removeKid(instance->model->getSceneGraph());
|
||||
|
||||
delete instance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// end of modelmgr.cxx
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
SG_USING_STD(vector);
|
||||
|
||||
// Don't pull in headers, since we don't need them here.
|
||||
class ssgSelector;
|
||||
class SGPropertyNode;
|
||||
class SGModelPlacement;
|
||||
|
||||
|
@ -48,6 +47,7 @@ public:
|
|||
Instance ();
|
||||
virtual ~Instance ();
|
||||
SGModelPlacement * model;
|
||||
SGPropertyNode_ptr node;
|
||||
SGPropertyNode_ptr lon_deg_node;
|
||||
SGPropertyNode_ptr lat_deg_node;
|
||||
SGPropertyNode_ptr elev_ft_node;
|
||||
|
@ -99,6 +99,7 @@ private:
|
|||
public:
|
||||
Listener(FGModelMgr *mgr) : _mgr(mgr) {}
|
||||
virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
|
||||
virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
|
||||
|
||||
private:
|
||||
FGModelMgr * _mgr;
|
||||
|
@ -109,8 +110,6 @@ private:
|
|||
|
||||
vector<Instance *> _instances;
|
||||
|
||||
ssgSharedPtr<ssgSelector> _selector;
|
||||
|
||||
};
|
||||
|
||||
#endif // __MODELMGR_HXX
|
||||
|
|
Loading…
Reference in a new issue