diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 836df56d5..27cc00eb9 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -171,23 +172,9 @@ FGAIBase::load3DModel(const string& fg_root, SGPropertyNode *prop_root, double sim_time_sec) { - // some more code here to check whether a model with this name has already been loaded - // if not load it, otherwise, get the memory pointer and do something like - // SetModel as in ATC/AIEntity.cxx - osg::Group* personality_branch = new osg::Group; - - //model = manager->getModel(path); - //if (!(model)) { - model = sgLoad3DModel(fg_root, - path, - prop_root, - sim_time_sec); - // manager->setModel(path, model.get()); - //} - personality_branch->addChild( model.get() ); - - return personality_branch; - //return model; + model = sgLoad3DModel(fg_root, path, prop_root, sim_time_sec); + model->setNodeMask(model->getNodeMask() & ~SG_NODEMASK_TERRAIN_BIT); + return model.get(); } bool FGAIBase::isa( object_type otype ) { diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index c5decd5e3..1b6bf324d 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -256,46 +256,6 @@ FGAIManager::loadScenarioFile(const std::string& filename) } } -// This code keeps track of models that have already been loaded -// Eventually we'd prbably need to find a way to keep track of models -// that are unloaded again -osg::Node* FGAIManager::getModel(const string& path) -{ - ModelVecIterator i = loadedModels.begin(); - //cerr << "Reference count summary " << endl; - int count = 0; - while (i != loadedModels.end()) - { - count += i->getNumRefs() -1; - //cerr << "Model " << i->getPath() << " has reference count of " << i->getNumRefs() << " "; - if (i->getNumRefs() == 1) - { - i = loadedModels.erase(i); - //cerr << "[ Deleted ]" << endl; - } - else - { - i++; - //cerr << endl; - } - } - //cerr << "Reference summary end : " << count << "models allocated" << endl; - i = loadedModels.begin(); - - while (i != loadedModels.end()) - { - if (i->getPath() == path) - return i->getModelId(); - i++; - } - return 0; -} - -void FGAIManager::setModel(const string& path, osg::Node *model) -{ - loadedModels.push_back(FGModelID(path,model)); -} - bool FGAIManager::getStartPosition(const string& id, const string& pid, SGGeod& geodPos, double& hdng, SGVec3d& uvw) { diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 4b6d4ef08..b88203d69 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -37,26 +37,9 @@ #include SG_USING_STD(list); -SG_USING_STD(vector); - -class FGModelID -{ -private: - osg::ref_ptr model; - string path; -public: - FGModelID(const string& pth, osg::Node* mdl) { path =pth; model=mdl;}; - osg::Node* const getModelId() const { return model.get();}; - const string & getPath() const { return path;}; - int getNumRefs() const { return model->referenceCount(); }; -}; - -typedef vector ModelVec; -typedef vector::iterator ModelVecIterator; class FGAIThermal; - class FGAIManager : public SGSubsystem { @@ -68,7 +51,6 @@ private: typedef ai_list_type::const_iterator ai_list_const_iterator; ai_list_type ai_list; - ModelVec loadedModels; public: @@ -99,9 +81,6 @@ public: void processScenario( const string &filename ); - osg::Node* getModel(const string& path); - void setModel(const string& path, osg::Node *model); - static SGPropertyNode_ptr loadScenarioFile(const std::string& filename); static bool getStartPosition(const string& id, const string& pid,